Reading RSS feed using jQuery

I am trying to show the name of my last stumbleupon element using their RSS feed and jquery. I have a function:

function get_stumbleupon() { $.get("http://rss.stumbleupon.com/user/fredkelly/", function(data) { alert(data.title); }, "xml"); } 

That doesn’t return anything ... I just want to get a few bits of information about one last item in the feed - how can I do this?

+4
source share
4 answers

Here's a tutorial on how to make an ajax cross domain using jQuery.

+4
source

Ólafur Waage gave a good cross-site request subject, but there is another article that is actually better for your Cross Site RSS reading .

+1
source

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> 
+1
source

As mentioned in the previous poster (Waage), you are probably running some scripts with multiple sites, which is a security violation for most browsers. What you need to do is create some kind of passage (the client makes a call to your site, your site loads other site content and returns it to the client).

This is usually pretty easy no matter which server you use. It also allows you to perform some additional functions with other people's data, such as caching.

0
source

Source: https://habr.com/ru/post/1286206/


All Articles