I am working with JSONP trying to get some results from the WOT API. See my code below:
// Prepare the URL var url='http://api.mywot.com/0.4/public_link_json?hosts=amazon.co.uk/&callback=cbfunc'; // Lookup $.getJSON(url, function(data){ alert('success'); });
It seems that for some reason it fails (as I am not warning in my browser). After some research, it seems that the returned JSONP takes place at the end of the callback function (between the most recent curly bracket and the closing bracket):
cbfunc({ "amazon.co.uk": { "target": "amazon.co.uk", "0": [ 95, 88 ], "1": [ 95, 87 ], "2": [ 95, 87 ], "4": [ 95, 87 ] } } )
After using the online JSON formatting (http://jsonformatter.curiousconcept.com/), does it seem like this single space throws the whole $ .getJSON () function because it cannot handle the space?
Is JSONP formatting really specific? I thought Javascript ignores spaces? Did I get the diagnosis right? Is there anything I can do to handle JSONP and remove the space?
Thanks in advance, and I'm using jquery BTW.
source share