Reputation: 3
I've searched everywhere but just can't solve this problem:
When i copy the content of the json file locally it works (without callback=?)
However when i do a crossdomain call i get the following error in the console:
Uncaught SyntaxError: Unexpected token :
this is my code:
var url='http://www.motor-forum.nl/json.php?type=json&callback=?';
$.getJSON(url,function(json){
$.each(json.globals, function(i,data){
$("#results").html(data.board_reactid);
});
});
Hopefully somebody can help me out here
Upvotes: 0
Views: 245
Reputation: 19672
I've just tried your API - it does not support JSONP. Getting stuff from remote servers isn't as simple as going &callback=?
on URLs - the remote server needs to openly support it.
JSONP works across cross-domain restrictions by loading the return in a script tag. This means that the object must be evaluable as a script. For JSONP, the user provides a callback name in the URL, and the return JSON object is then wrapped in a function call to it (myCallBackName({object});
).
Upvotes: 1