Suresh Kumar Medasani
Suresh Kumar Medasani

Reputation: 13

unable to get the results from the yahoo finance api for my site due cross domain funcationality

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); } }

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.

Upvotes: 0

Views: 356

Answers (1)

Pankaj Khairnar
Pankaj Khairnar

Reputation: 3118

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

Upvotes: 1

Related Questions