使用jQuery阅读RSS feed? [英] Reading RSS feed with jQuery?

查看:130
本文介绍了使用jQuery阅读RSS feed?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery rss插件 jFeed ,并使用其示例代码在他们的网站上,我创建了以下似乎无效的代码:

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);
    }
});

我收到一条消息:

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

谁知道我为什么收到此访问控制消息?这个rss feed在我的台式机和在线rss阅读器中都可以正常工作...

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

推荐答案

警告

Google Feed Feed 已正式弃用不再起作用

无需插件即可轻松完成,返回的数据将保存在json

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);
        }
    });
    });

只需确保它指向 xml 文件,然后将url更改为url Rss feed,

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

这篇关于使用jQuery阅读RSS feed?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆