Demo 14 :: JSON

JSON is javascript object notation. It is a way for storing data and it is easy for computers to transfer the information from one to the other. JQuery makes it easy to use JSON which you can see in this demo.

View the HTML code

<div id="flickrImages"></div>

View the jQuery code

$(document).ready(function(){
	$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",//calls the images from the public flickr feed
	{//parameters for the search
		tags: "flowers",//pulls images of flowers
		tagmode: "any",//flickr tagmode pulls either all or any of the tags
		format: "json"
	},
	function(data) {
		$.each(data.items, function(i,item){//collects each data item
			$("<img/>").attr("src", item.media.m).appendTo("#flickrImages");//puts the items into an image tag and then appends it to the div
			if ( i == 5 ) return false;//after 6 images it stops pulling
		});
	});
});