Displaying Flickr photos

To search photos from Flickr, we will use the Flickr tags search API. The API is very simple to implement and provides the JSON format in response apart from XML. Since we will have to make a cross-domain request in order to contact the API, we will use JSONP to fetch the data. The Flickr API allows a callback parameter in the URL for JSONP requests. To implement the Flickr API, go to the initFlickr method in your file and write the following code inside it:

$.getJSON('https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?', { tags: 'cat', format: 'json' }, function(data) { var str = ''; $.each(data.items, function(i,item) { str+= '<li>'; str+= '<a class="media" href="javascript:;" data-img="' + item.media.m ...

Get Mastering jQuery UI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.