I'm trying to load a RSS feed using Google's Feed API which gives me a JSON string.
(documentation: https://developers.google.com/feed/).
However, I'm trying to use jQuery's AJAX instead of vanilla JavaScript XHR. It is not working for some reason, which I can't identify why. Loading the URL in the browser works, however (get the link in the code below).
I have prepared a jsFiddle: http://jsfiddle.net/gberger/fNwpD/
$.ajax({
url:'http://ajax.googleapis.com/ajax/services/feed/load?hl=ja&output=json-in-script&q=http%3A%2F%2Ffeeds.gawker.com%2Flifehacker%2Ffull&v=1.0&num=3',
success: function(data){
alert(JSON.stringify(data));
},
error: function(error){
alert(this.url);
alert(JSON.stringify(error));
}
});
Simply add dataType: 'jsonp'
to your options object. Your code is not working because of the Same-origin policy. JSONP is one way of dealing with this if the server supports it (Feed API does).
$.ajax({
url: 'xy',
success: function () {},
error: function () {},
dataType: 'jsonp'
});