jsonp example

by jamitzky

HTML

<html><body>
    Loads the four most recent <b>cat pictures</b> from the Flickr JSONP API.
<div id="images"/>
</body></html>

CSS

img {max-width:80px; max-height:80px}

JavaScript

$.getJSON( "http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?", 
  function(data){
  $.each(data.items, 
    function(i,item){
$("<img/>").attr("src", item.media.m).appendTo("#images").wrap("<a href='" + item.link + "'></a>");
    if ( i == 3 ) return false;});
});