Is there a question icon because you specified a JSONP callback function? in the query string (i.e. &jsonp=? ). Due to security issues (in particular, policies of the same origin ), you cannot complete an AJAX request to a site outside the same domain as the page on which you are located. To get around this, JSONP works by creating a script tag, with SRC set to the script url on another site. This will load the external JavaScript file and run any code. Now, to associate this external code with your JavaScript, the external API accepts the name of the function to call ( &jsonp=functionnametocall ). The returned JavaScript calls this function and passes the data that it tries to return as a JSON object as the first argument.
So the reason you see the question mark when you go there is because you pass the question mark to the jsonp query string parameter. jQuery automatically converts the question mark into a url like http://www.test.com/api/apikey=292929&callback=? , into a function with a unique name. This is handled in the background by jQuery, so you don't need to think about it.
Now, I said, I don't know if jQuery defines if the name of the callback parameter is something other than callback=? . $.getJSON() , however, is a short form for longer:
$.ajax({ url: url, dataType: 'json', data: data, success: callback });
I suggest you try directly using $.ajax() and set the jsonp parameter to "jsonp" . This tells $.ajax() that the query string parameter is called jsonp , not callback . So like this:
$.ajax({ url: url, dataType: 'json', data: data, success: callback, jsonp:"jsonp" });
Additional information: $. getJSON | $. ajax ()
Richard Marskell - Drackir Mar 22 2018-11-11T00: 00Z
source share