Last active
February 8, 2017 05:09
-
-
Save trmtsy/1037400 to your computer and use it in GitHub Desktop.
FlickrAPIを利用してバプリックな写真を読み込みます。
This file contains hidden or 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="ja"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Flickr API</title> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
function ajaxStart () { | |
$.ajax({ | |
url: "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", | |
data: {format: 'json'}, | |
dataType: "jsonp", | |
error: function(xhr, textStatus, errorThrown) { | |
}, | |
success: function(data, textStatus, xhr) { | |
for (var i = 0, length = data.items.length; i < length; i++) { | |
var item = data.items[i]; | |
$('#loadArea').prepend($('<img>').attr('src', item.media.m)); | |
} | |
} | |
}); | |
} | |
</script> | |
</head> | |
<body id="content"> | |
<button onclick="javascript:ajaxStart();">パブリック読み込み</button> | |
<div id="loadArea"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment