Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading RSS feed with jQuery?

Using the jQuery rss pluging jFeed, and using their example code on their website, I have created the following code which does not seem to work:

jQuery.getFeed({
    url: 'http://www.hotukdeals.com/rss/hot',
    success: function(feed) {
        alert(feed.title);
    }
});

I get a message saying:

XMLHttpRequest cannot load http://www.hotukdeals.com/rss/hot. Origin http://intranet is not allowed by Access-Control-Allow-Origin.

Anyone know why I am getting this access control message? This rss feed works fine in my desktop and online rss readers...

like image 862
oshirowanen Avatar asked Jul 05 '12 14:07

oshirowanen


1 Answers

WARNING

The Google Feed API is officially deprecated and doesn't work anymore!

It can be done very easily without a plugin and the returned data would be in json

        $(function(){
        url = 'http://www.thetutlage.com/rss.xml';
        $.ajax({
        type: "GET",
        url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeURIComponent(url),
        dataType: 'json',
        error: function(){
            alert('Unable to load feed, Incorrect path or invalid feed');
        },
        success: function(xml){
            values = xml.responseData.feed.entries;
            console.log(values);
        }
    });
    });

Just make sure it points towards an xml file and change the url to url Rss feed,

like image 96
Aman Virk Avatar answered Sep 19 '22 13:09

Aman Virk