JSONP request using jquery $.getJSON not working on well formed JSON.

Posted by Antti on Stack Overflow See other posts from Stack Overflow or by Antti
Published on 2010-03-11T15:26:18Z Indexed on 2010/03/11 20:59 UTC
Read the original article Hit count: 483

Filed under:
|
|
|

I'm not sure is it possible now from the url I am trying. Please see this url: http://www.heiaheia.com/voimakaksikko/stats.json

It always serves the same padding function "voimakaksikkoStats". It is well formed JSON, but I have not been able to load it from remote server. Does it need some work from the server side or can it be loaded with javascript? I think the problems gotta to have something to with that callback function...

JQuery is not requirement, but it would be nice.

This (callback=voimakaksikkoStats) returns nothing (firebug -> net -> response), and alert doesn't fire:

$.getJSON("http://www.heiaheia.com/voimakaksikko/stats.json?callback=voimakaksikkoStats", function(data){
    alert(data);
})

but this (callback=?):

 $.getJSON("http://www.heiaheia.com/voimakaksikko/stats.json?callback=?", function(data){
    alert(data);
})

returns:

voimakaksikkoStats({"Top5Sports":[],"Top5Tests":{"8":"No-exercise ennuste","1":"Painoindeksi","2":"Vy\u00f6t\u00e4r\u00f6n ymp\u00e4rys","10":"Cooperin testi","4":"Etunojapunnerrus"},"Top5CitiesByTests":[],"Top5CitiesByExercises":[],"ExercisesLogged":0,"Top5CitiesByUsers":[""],"TestsTaken":22,"RegisteredUsers":1});

But I cannot access it... In both examples the alert never fires. Can someone help?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jsonp