Last.FM API V2
by bluetidepro
HTML
<ul id="posts">
<li><h2>MUSIC!</h2><hr/></li>
</ul>
<a href="#" id="json_click_handler">Load . . .</a>
CSS
body{padding:20px;}h2{font-weight:bold;}
JavaScript
$(document).ready(function() {
i = 0;
doAjaxRequest(i);
$('#json_click_handler').on('click', function(event) {
event.preventDefault();
i = i + 10;
doAjaxRequest(i);
});
function doAjaxRequest(i) {
$.ajax({
type: "GET",
url: "http://api.tumblr.com/v2/blog/blog.iamzachreed.com/posts/quote/",
dataType: "jsonp",
data: {
api_key: "dqtYbaUpm3nHu5kKJDCA2eywPrwqSgP2CfnHAuboBC55JlhQQD",
limit: "10",
offset: i,
jsonp: "jsonCallback"
}
});
jsonCallback = function(json) {
if (json.response.posts != '') {
$.each(json.response.posts, function(index, item) {
var quote_id = item["text"];
// alert(quote_id);
$('#posts').append('<li>' + quote_id + '<hr/></li>');
});
//alert(i);
} else {
alert('NO MORE POSTS TO LOAD!');
document.getElementById("sound").innerHTML = "<embed src='http://dcc.ndhu.edu.tw/monbaza/soundbook/sound/dog_bark_front.mp3' hidden=true autostart=true loop=false>";
};
};
};
});