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.

Community
  • 1
  • 1
Vinny
  • 309
  • 3
  • 11

1 Answers1

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.

stewe
  • 41,820
  • 13
  • 79
  • 75