Skip to content Skip to sidebar Skip to footer

Yahoo Forecastjson Gives Xml Error

After browsing through this site, I found that you can get Yahoo weather in a JSON format using forecastjson. When I run: $.getJSON('http://weather.yahooapis.com/forecastjson?w=211

Solution 1:

Using JSON doesn't mean that you will not encounter cross domain problem. That is an object standard.

If you want to make a cross domain request, you should use JSONP.

The url that you are trying to request, doesn't support JSONP request. But you can use YQL instead of that.

here is an example,

var query = escape('select item from weather.forecast where woeid="2295424"');
var url = "http://query.yahooapis.com/v1/public/yql?q=" + query + "&format=json&callback=c"; 

$.getJSON(url, function(data) {
   console.log(data);
});​

And here is the URL that you can check json result.

DEMO

Post a Comment for "Yahoo Forecastjson Gives Xml Error"