0

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

1 Answers1

1

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});).

Sébastien Renauld
  • 19,203
  • 2
  • 46
  • 66
  • I have answered this multiple times already - http://stackoverflow.com/questions/15670082/getjson-parsererror-trying-to-call-api/15670216#15670216 being one of them. If your hosting provider allows it, use ProxyPass and ProxyPassReverse directives in Apache (or proxy_pass in nginx) to reverse proxy the request and turn it into a local URL, where you'll be able to use regular ajax. If you can't do that, email the devs and ask them to support jsonp. If you can't do either... then you're stuffed :-( – Sébastien Renauld Apr 01 '13 at 14:20