Last active
December 27, 2015 11:29
-
-
Save claudiosanches/7318980 to your computer and use it in GitHub Desktop.
Get feed with jQuery
This file contains hidden or 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
| <!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