Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The question mark is there because you specified the JSONP callback function to be ? in your query string (ie. <code>&amp;jsonp=?</code>). Due to security concerns (specifically the <a href="http://en.wikipedia.org/wiki/Same_origin_policy" rel="nofollow">same-origin policy</a>) you cannot do an AJAX request to a site outside the same domain as the page you're on. To get around this, JSONP works by creating a script tag, with the SRC set to the URL of the script on the other site. This will load the external JavaScript file and run whatever code is there. Now, in order to link that external code with your JavaScript, the external API takes the name of a function to call (<code>&amp;jsonp=functionnametocall</code>). The returned JavaScript calls that function and passes in the data it's trying to return as a JSON object as the first argument.</p> <p>So, the reason you see the question mark when you go there is because you're passing a question mark to the jsonp query string parameter. jQuery will automatically convert the question mark in a url such as <code>http://www.test.com/api/apikey=292929&amp;callback=?</code> to a uniquely named function. This is handled in the background by jQuery so you don't have to think about it.</p> <p>Now, that said, I don't know if jQuery detects if the name of the callback parameter as being something other than <code>callback=?</code>. <code>$.getJSON()</code> however is a short form for the longer:</p> <pre><code>$.ajax({ url: url, dataType: 'json', data: data, success: callback }); </code></pre> <p>I suggest you try using <code>$.ajax()</code> directly and set the <code>jsonp</code> setting equal to <code>"jsonp"</code>. This tells the <code>$.ajax()</code> method that the query string parameter is called <code>jsonp</code> and not <code>callback</code>. So like this essentially:</p> <pre><code>$.ajax({ url: url, dataType: 'json', data: data, success: callback, jsonp:"jsonp" }); </code></pre> <p>More information: <a href="http://api.jquery.com/jQuery.getJSON/" rel="nofollow">$.getJSON</a> | <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">$.ajax()</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload