Remote Scripting with JSONP and jQuery


Using JSONP allows for cross-domain HTTP GET requests. The following code uses jQuery to call the Flickr API for a list of photos returned in JSON.

<div id="photos"></div> $.ajax({     type: 'GET',     url: '',     dataType: 'jsonp',     success: function(data){         $.each(data.items, function(i, item){             $('<img/>').attr('src','#photos');         });     } }); NOTE: Updating is also possible using a GET request, but limited to around 2000 characters for some browsers and not recommended.