Changing getJSON to JSONP

javascript, jquery, json, jsonp

Solution

Actually, you just have to add `?callback=?`, jQuery does the rest.

$(document).ready(function() {
    $.getJSON('http://example.com/api/get_cats?callback=?', function(fbResults) {
        document.write(fbResults.cats[0].title);
    });
});

Problem

I have this code: ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script> $(document).ready(function() { $.getJSON('http://example.com/api/get_cats', function(fbResults) { document.write(fbResults.cats[0].title); }); }); </script> ``` How can I change this code: ``` <script> $(document).ready(function() { $.getJSON('http://example.com/api/get_cats', function(fbResults) { document.write(fbResults.cats[0].title); }); }); </script> ``` for it to work as JSONP ... Is this totally different?

Original source