The above code showing status 200 in IE But in Firefox and Chrome got the status 0 due cross domain functionality. Can any one help to how to overcome this cross domain functionality using java script.
0
votes
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","http://finance.yahoo.com/d/quote.csve=.csv&s=^BSESN&f=nl1c2vgh&random=10",true);
xmlhttp.send(null);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4)
{
window.alert(xmlhttp.status);
}
}
Nope, but you could do it on the serverside?
– adeneo
can use Yahoo YQL to access it. It is a cross domain proxy
– charlietfl
1 Answers
1
votes
Direct call to other domain is not possible from JavaScript ajax due to cross domain issue best way to do this type of call is call your own webpage using Ajax and from your server side script call these apis and get answer and return to your ajax call.
if you are using php you can use cURL OR file_get_contents to fetch content from url