Skip to content

Instantly share code, notes, and snippets.

@fredrick
Created September 23, 2011 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredrick/1237561 to your computer and use it in GitHub Desktop.
Save fredrick/1237561 to your computer and use it in GitHub Desktop.
RSS Widget
<div class="feed">
<script type="text/javascript">
(function(url, callback) {
jQuery.ajax({
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
dataType: 'json',
success: function(data) {
callback(data.responseData.feed);
}
});
})('http://news.ycombinator.com/rss', function(feed){ // Change to desired URL
var entries = feed.entries;
for (var i = 0; i < entries.length; i++) {
jQuery('.feed > ul').append('<li><a href="' + entries[i].link + '">' + entries[i].title + '</a></li>');
}
});
</script>
<!--Change me-->
<h4>Hacker News</h4>
<ul></ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment