Skip to content

Instantly share code, notes, and snippets.

@jbr
Created November 27, 2010 02:53
Show Gist options
  • Save jbr/717509 to your computer and use it in GitHub Desktop.
Save jbr/717509 to your computer and use it in GitHub Desktop.
load an rss feed w/ jquery through google
$(function () { //assuming jquery and an <OL id="blog"></OL>
$.loadRSS = function (url, callbackName, num) {
$(document.body)
.append('<script src="' +
'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=' +
url +
'&callback=' + callbackName + '&num='+num || 10+'">' +
'</script>')
}
window.processRSS = function (data) {
$.each (data.responseData.feed.entries, function (i, entry) {
$('ol#blog')
.append('<li>' +
'<h3>' + entry.title + '</h3>' +
'<span class="date">' + (new Date(entry.publishedDate)).toDateString() + '</span>' +
'<p>' + entry.contentSnippet + '</p>' +
'<a class="read-more" href="'+entry.link+'">Read More&hellip;</a>' +
'</li>')
})
}
$.loadRSS('http://feeds.nytimes.com/nyt/rss/HomePage', 'processRSS', 10)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment