0

Possible Duplicate:
XML parsing in jquery doesn't seem to work for me
Access-Control-Allow-Origin error sending a jQuery Post to Google API's

I'm trying to load data from Google's weather API. When I run this code:

$.ajax({ 
    type: "GET",
    url: "http://www.google.com/ig/api?weather=13210",
    dataType: "xml",
    success: function(xml) {   } 
});

I get the following message: XMLHttpRequest cannot load http://www.google.com/ig/api?weather=13210. Origin null is not allowed by Access-Control-Allow-Origin.

Why am I getting this message? I am new to loading XML into jquery.

3
  • 1
    Seems like this was asked before: stackoverflow.com/questions/6114436/… Commented Apr 26, 2012 at 5:34
  • check edit ansser of mine ... Commented Apr 26, 2012 at 6:00
  • dont forget to upvote and mark answer as accepted if you got the info you want .. Commented Apr 26, 2012 at 14:55

1 Answer 1

2

Unfortunately there is no way you can directly load the XML from

http://www.google.com/ig/api?weather=13210

using only jQuery/JavaScript. The Same origin policy prevents that. And Google does not send an Access-Control-Allow-Origin header either (which could allow access).

The only way is to load it from server-side.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.