I'm trying to extract some data from the Premier League Fantasy Football site and falling short on what feels like a catch 22.
My AJAX JSONP script looks like the following:
function getPlayer(playerNumber) {
$.ajax({
url: 'http://fantasy.premierleague.com/web/api/elements/' + playerNumber + '/',
dataType: 'jsonp',
success : function(responseText) {
alert(responseText);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
if (XMLHttpRequest.status != 200)
alert('getPlayer failed!');
},
complete : function(jqXHR) {
alert('complete');
}
});
}
This generates the error SyntaxError: missing ; before statement
I believe because of the accepted answer on this page: AJAX call and clean JSON but Syntax Error: missing ; before statement
Changing the dataType to json means I fall foul of the same origin policy as described there.
The thing that irks me is that when I use the JSONP version, I get status 200 and I can see the full 'object' structure in my Firefox debugger.
So what is it that Firefox is doing to get at the data that I'm not?