Created
August 5, 2012 17:03
-
-
Save alicial/3265951 to your computer and use it in GitHub Desktop.
How to Display Recent Posts in Tumblr
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
$(function() { | |
var url = '/rss'; | |
var $list = $('#recent-posts'); | |
$.ajax({ | |
url: url, | |
type: 'GET', | |
dataType: 'xml', | |
success: function(data) { | |
var $items = $(data).find('item'); | |
$items.each( function() { | |
var $item = $(this); | |
var link = $item.children('link').text(); | |
var title = $item.children('title').text(); | |
if (link && title) { | |
$list.append($('<li><a href="' + link + '">' + title + '</a></li>')); | |
} | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment