Skip to content

Instantly share code, notes, and snippets.

@tyrostone
Created February 26, 2015 17:25
Show Gist options
  • Save tyrostone/a64a5698285771f193ee to your computer and use it in GitHub Desktop.
Save tyrostone/a64a5698285771f193ee to your computer and use it in GitHub Desktop.
jQuery.getJSON demo
<!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