Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Last active December 27, 2015 11:29
Show Gist options
  • Save claudiosanches/7318980 to your computer and use it in GitHub Desktop.
Save claudiosanches/7318980 to your computer and use it in GitHub Desktop.
Get feed with jQuery
<!DOCTYPE html>
<html>
<head>
<title>Feed</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<script>
jQuery(document).ready(function($) {
var url = 'http://claudiosmweb.com/feed/',
qty = '5'
feed_json = 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=' + qty + '&callback=?&q=' + encodeURIComponent(url);
$.ajax({
url: feed_json,
dataType: 'json',
success: function(data) {
var items = data.responseData.feed.entries;
console.log(items);
html = '';
$.each(items, function(i, item) {
html += '<li><a href="' + item.link + '">' + item.title + '</a><br />' + item.contentSnippet + '</li>';
});
$('body').append('<ul>' + html + '</ul>');
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment