jQuery提取多个RSS提要 [英] JQuery Fetch Multiple RSS feeds
本文介绍了jQuery提取多个RSS提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取多个RSS来源并在每个来源的Div
中显示它们?
How can I fetch multiple RSS sources and display them in lets say a Div
for each source?
类似的事情几乎可以做到,但是我不知道如何创建多个RSS源:
Something like this would almost do it, but I dont know how to feetch multiple RSS sources:
$(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);
}
});
});
我想要一个这样的结构:
I want a structure like this:
<div id="bbc">BBC rss feeds here</div>
<div id="dailyMail">daily Mail rss feeds here</div>
etc...etc...
预先感谢
推荐答案
仅循环通过一系列源URL
Just loop trough array of source urls
$(function () {
var urls = ['http://www.thetutlage.com/rss.xml', 'example.net', 'another.example.net'];
for (var i = 0; i < urls.length; i++) {
$.ajax({
type: "GET",
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeURIComponent(urls[i]),
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);
}
});
}
});
这篇关于jQuery提取多个RSS提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文