I am trying to make a jQuery .ajax() call on a public web service and I am unable to find the correct syntax.
I tried several different implementations. It:
$.ajax({ url: 'http://www.geognos.com/api/en/countries/info/all.jsonp', dataType: "jsonp", success: function() { alert('JSONP call succeeded!'); } });
The following error failed:
all.jsonp:1 Uncaught ReferenceError: callback is not defined
And this one:
$.ajax({ url: 'http://www.geognos.com/api/en/countries/info/all.json', dataType: "json", success: function() { alert('JSON call succeeded!'); } });
Cannot execute this error:
XMLHttpRequest cannot load http://www.geognos.com/api/en/countries/info/all.json. Origin http://localhost:8888 is not allowed by Access-Control-Allow-Origin.
I serve the page through my local IIS7 instance. I also tried various combinations of $.getJSON() with similar results. What am I missing?
Here is the JSFiddle of the specified code.
UPDATE: We thought we had a solution, but I still get a callback is not defined error when making JSONP calls, even though the warning / log code is being called. The response URL is as follows:
http://www.geognos.com/api/en/countries/info/all.jsonp?callback=undefined&157148585
and the JSON response is wrapped as follows:
callback({"StatusMsg": "OK", "Results": {"BD": {"Name": "Bangladesh", "Capital": {"DLST": "null", "TD": 6.0, "Flg": 2, "Name": "Dhaka", ...
I found examples with a callback name appended to the end of the URL in the .ajax() configuration, but when I try to get the same result, it is only bound to the end of the query string.