Help - Search - Members - Calendar
Full Version: Issue With Xmlhttp Request
Zymic Webmaster Forums > Web Design & Development > Client Side Scripting > JavaScript
chrislaughlin
Im trying to add a twitter trends section to my web site, im trying to do this using the json object that twitter provides from accessing this URL (http://api.twitter.com/1/trends.json) when i use the following code i see the below error. Does anyone know where im going wrong ?

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://api.twitter.com/1/trends.json",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
if (xmlhttp.status!=404) {
alert(xmlhttp.responseText);
}
}
}
xmlhttp.send(null);

Error :

XMLHttpRequest cannot load http://api.twitter.com/1/trends.json. Origin null is not allowed by Access-Control-Allow-Origin.


This was tested in chrome but worked in IE and idea's ?
ssfdre38
its due the fact that ALL remote connections are NOT allowed on Zymic
ThomasNJ
QUOTE(ssfdre38 @ Aug 4 2011, 12:27 AM) *
its due the fact that ALL remote connections are NOT allowed on Zymic

what if I only trying to load the local file? Like bellow:
CODE
    if (window.XMLHttpRequest){
        xmlhttp=new XMLHttpRequest();
    }else{
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    var xmlPath="http://myzymicID.zxq.net/"+"Assets/"+document.title+".xml";
    xmlhttp.open("GET",xmlPath,false);
// by using "false" at async, the script will not go pass this line. But if I change to "true", it will just hang in xmlhttp.readyState ==0 and page not found
    xmlhttp.send(null);
    xmlDoc = xmlhttp.responseXML;
    var photoX = xmlDoc.getElementsByTagName("photoX");
    
    var photoIcons=new Array();
    var photoTips=new Array();
//..... and so on and so to load my photos


The same script works elsewhere, but just not here, is there anything I need to change in order for my photo album to load out of the xml file?
ssfdre38
dont add the http://myzymicID.zxq.net/ and then the server wont read it as remote connections and will allow you to use it
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.