0

Possible Duplicate:
jQuery.getJSON( url, [data], [callback] )

How can you do cross-domain request?

$.getJSON('http://www.google.com/ig/calculator?hl=en&q=1EUR%3D%3FUSD'+'&callback=?', function(data){
    alertobj(data);
});

The request is sent and the data is recieved, but an error is returned

invalid label
[Break on this error] {lhs: "1 Euro",rhs: "1.4409 U.S. dollars",error: "",icc: true}
Community
  • 1
  • 1
clarkk
  • 27,151
  • 72
  • 200
  • 340
  • 1
    You can't do an Ajax request to a domain different than the one you're on. – Pekka Aug 22 '11 at 21:45
  • what are the alternatives then? – clarkk Aug 22 '11 at 21:45
  • is the only alternative to do the requst to google through my own server via PHP etc? – clarkk Aug 22 '11 at 21:48
  • 1
    that, or see whether the service supports JSONP - you can do JSONP requests from JavaScript to other hosts – Pekka Aug 22 '11 at 21:49
  • Do an ajax request to a local server-side file that requests the information cross-domain. Such as using PHP to grab the info from google and then using your ajax request to access the local PHP file. – Jasper Aug 22 '11 at 21:49
  • @ pekka.. what do you mean by JSONP requests can do cross domain? – clarkk Aug 22 '11 at 21:55
  • I found some code.. the request is made and the data is recieved, but I get an error.. have updated my question – clarkk Aug 22 '11 at 22:12

0 Answers0