The JSON is coming from remote domain. But when I am trying using the code below it given some errors: "XMLHttpRequest cannot load testsite2.com/api. Origin null is not allowed by Access-Control-Allow-Origin." and "Uncaught TypeError: Cannot read property 'test_data' of null" and "Failed to load resource". My code is given below:
<pre><code>$.getJSON(STACK_AUTH_API_SITE, function(data) {
$('#data').html('<p>' + data.test_data[0].name + '</p>'
+ '<p>' + data.test_data[0].url + '</p>');
});</code></pre> — Chanchal Kumar Ghosh over 8 years ago

Ok well the second error is because of the 1st one anyway, so fix that and they should both go away ;) The format of the request is wrong for JSONP, you need to move the anonymous function out of the method argument and define it as a normal callback function, then add the name of the callback function to the URL as a query string — danwellman over 8 years ago