I am trying to do a cross domain request within jquery, in a function like the one found in this gist
I thought I had incorrect JSON, but this is what I get from the response:
{"status":"OK","errorMessage":"","numberOfResults":10,"suggestions":[{"url":"http://dbpedia.org/resource/Bassiana","label":"Bassiana","owner":0},{"url":"http://dbpedia.org/resource/Julia_Soaemias_Bassiana","label":"Julia Soaemias Bassiana","owner":0},{"url":"http://dbpedia.org/resource/Julia_Bassiana","label":"Julia Bassiana","owner":0},{"url":"http://dbpedia.org/resource/Varius_Avitus_Bassianus_Marcus_Aurelius_Antoninus","label":"Varius Avitus Bassianus Marcus Aurelius Antoninus","owner":0},{"url":"http://dbpedia.org/resource/Bassianus_%28senator%29","label":"Bassianus (senator)","owner":0},{"url":"http://dbpedia.org/resource/Johannes_Bassianus","label":"Johannes Bassianus","owner":0},{"url":"http://dbpedia.org/resource/Julius_Bassianus","label":"Julius Bassianus","owner":0},{"url":"http://dbpedia.org/resource/Bassian_thrush","label":"Bassian thrush","owner":0},{"url":"http://dbpedia.org/resource/Bassianae","label":"Bassianae","owner":0},{"url":"http://dbpedia.org/resource/Bassian","label":"Bassian","owner":0}]}
How am I supposed to make it work? It seems the callback is never fired since the JSON is not valid.
The problem is not that it’s invalid (as passing it though this site will confirm), it’s that it’s never “wrapped” in a callback method.
Look up JSONp.
If you were to call
/getMyJSON?callback=myCallbackyour JSONP response should come back like:(Note that it’s now wrapped in a function call that you should have defined on your page, and ready for processing the returned results).