Hello,
I am trying to make AJAX get the content from the page http://creativescream.com/html5ws/api/news asynchronously. When i am following the guide by W3SCHOOLS and type exactly the same code but if i just replace the code that goes like:
xmlhttp.open("GET","ajax_info.txt",true);
into this:
xmlhttp.open("GET","http://creativescream.com/html5ws/api/news",true);
I get no result. this is my whole code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://creativescream.com/html5ws/api/news",true);
xmlhttp.send();
}
</script>
<title>HTML5 WorkShop Gazette</title>
</head>
<body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
What i really need to make is to use AJAX and JASON to use the info from the link i provided and place them somewhere on the html page. I have a feel like i am missing a step somewhere but I am very new with this AJAX/JASON stuff so I am also finding it a bit hard to understand how those two go together. Any help would be very appreciated.
Thanks
Dushan