Reading RSS feed using jQuery
15,691
Solution 1
Here's a tutorial on how to do Cross domain ajax with JQuery.
Solution 2
Ólafur Waage gave a good cross site request topic, but there is also another post that actually fits better with your Cross Site RSS reading problem.
Solution 3
Here is my little script:
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery.ajax({
url: "/feed.xml", // RSS url
success: function(msg){
jQuery('#blip').html(''); // where to put RSS
jQuery('entry',msg).slice(0,3).each(function(){ // slice: get only first 3 posts
var html = '<div>';
var upd = jQuery('updated', this).text().replace(/[TZ]/g, ' ');
var upd = jQuery.trim(jQuery('updated', this).text());
upd = upd.replace(/-/g,"/").replace(/T/," ").replace(/Z/," UTC");
upd = upd.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2");
updf = new Date(upd).toLocaleString();
html += '<p class="post_date">' + updf + '</p>';
html += '<div class="post_content"><span>' + jQuery('content', this).text() + '</span></div>';
html += '</div>';
jQuery(html).appendTo('#blip');
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown);}
});
});
</script>
Author by
Fred
Updated on June 04, 2022Comments
-
Fred about 2 years
I'm trying to show the title of my latest stumbleupon item using their RSS feed and jquery. The function I have is:
function get_stumbleupon() { $.get("http://rss.stumbleupon.com/user/fredkelly/", function(data) { alert(data.title); }, "xml"); }
Which returns nothing... I just simply want to get a few bits of info about the single latest item in the feed - how can I do this?
-
Josh over 13 yearsWithin that tutorial make sure to follow the link to the "universal RSS to JSON converter".
-
jamesmortensen over 13 yearsThis is basically what's known as a "proxy server" for those not familiar with Richard's solution.