Created
February 26, 2015 17:25
-
-
Save tyrostone/a64a5698285771f193ee to your computer and use it in GitHub Desktop.
jQuery.getJSON demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>jQuery.getJSON demo</title> | |
<style> | |
img { | |
height: 100px; | |
float: left; | |
} | |
</style> | |
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> | |
</head> | |
<body> | |
<div id="images"></div> | |
<script> | |
(function() { | |
var flickerAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?"; | |
$.getJSON( flickerAPI, { | |
tags: "mount rainier", | |
tagmode: "any", | |
format: "json" | |
}) | |
.done(function( data ) { | |
$.each( data.items, function( i, item ) { | |
$( "<img>" ).attr( "src", item.media.m ).appendTo( "#images" ); | |
if ( i === 3 ) { | |
return false; | |
} | |
}); | |
}); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment