we are trying to consume a feed from a web site. We have tried different approaches but none of them are working:
Approach 1: Trying to get the content and parse it manually
$.get("http://www.wwe.com/feeds/sapphire/news/all/all/0,1", {}, function(data){
alert(data);
});
we always get an empty response. If you paste the URL in the browser window you get a valid response (http://www.wwe.com/feeds/sapphire/news/all/all/0,1)
Approach 2: Using jsonP
We have this code:
$.ajax({
url: "http://www.wwe.com/feeds/sapphire/news/all/all/0,1",
dataType: 'jsonp',
data: {},
error: function (jqXHR, textStatus,errorThrown) {
console.log("error");
},
contentType: "application/json",
success: function (data, textStatus, jqXHR) {
console.log('success_function');
console.log(data);
}
});
Server is responding with invalid label. It seems that in the response the callback function is missing. Any help will be appreciated.
It appears that the service you are attempting to load from doesn't support jsonp. Without this you can't do a straight jquery ajax call to it across domains.
See: JSON cross site without JSONP
You can test this by keeping your code the same and testing a url that does support jsonp (e.g. https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=espn&count=1)
The only alternative appears to create a proxy on your sever to pass the data through to your javascript.