使用 jQuery rss 插件 jFeed ,并使用他们网站上的示例代码,我创建了以下似乎不起作用的代码:
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 提要在我的桌面和在线 RSS 阅读器中运行良好...
最佳答案
警告
The Google Feed API is officially deprecated and doesn't work anymore!
无需插件即可轻松完成,并且返回的数据为 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,
关于jquery - 使用 jQuery 读取 RSS 提要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11346990/