user1947215
user1947215

Reputation: 33

Get JSON data from URL using AJAX if possible

I want to get the JSON data from the URL below and use it in my webpage in any way possible, can it be done?

http://fantasy.premierleague.com/web/api/elements/100/

(Note I do not own this site, I'm just using the data for a simple free app.)

If I simply enter the URL into the browser it works but that's no good as I want my page to use the data, so an AJAX request would be ideal but I cannot get it to work. I've tried using a jQuery AJAX call but cannot get it to work.

I'm staring to think it's not possible from within the browser and I would need to use Mechanize or something like that, which is not really an option.

Thanks.

Upvotes: 3

Views: 51175

Answers (1)

James Kleeh
James Kleeh

Reputation: 12228

I had this working, and now the error function is getting executed with a 200 status code. Is it possible they limit the number of queries per x seconds because it is working intermittently.

Edit: Something is going on with their caching. Stuff is jacked.

$.ajax({
    type:"GET", 
    url: "http://fantasy.premierleague.com/web/api/elements/100/", 
    success: function(data) {
            $("body").append(JSON.stringify(data));
        }, 
    error: function(jqXHR, textStatus, errorThrown) {
            alert(jqXHR.status);
        },
   dataType: "jsonp"
});​​​​​​​​​​​​​​​

Upvotes: 8

Related Questions