Dushan69 Posted May 26, 2012 Share Posted May 26, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263168-ajax-get-url-issue/ Share on other sites More sharing options...
smoseley Posted May 26, 2012 Share Posted May 26, 2012 I've never done cross-domain AJAX requests before, but I believe you're experiencing a sandbox issue. I've heard of people using JSONP for cross-site AJAX, but I'm not really familiar with the protocol. Try googling it. Quote Link to comment https://forums.phpfreaks.com/topic/263168-ajax-get-url-issue/#findComment-1348776 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.