bbe*_*ord 3 javascript rss jquery
我一直在努力使用jQuery.get()来引入我的动态生成的RSS提要,而我只有问题,我的RSS源是错误的格式吗?如果是这样我可以使用javascript将其转换为正确的格式?
这是我的饲料:http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id = 0
这是我的代码:
function get_rss_feed() {
$(".content").empty();
$.get("http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id=0", function(d) {
var i = 0;
$(d).find('item').each(function() {
var $item = $(this);
var title = $item.find('title').text();
var link = $item.find('link').text();
var location = $item.find('location').text();
var pubDate = $item.find('pubDate').text();
var html = '<div class="entry"><a href="' + link + '" target="_blank">' + title + '</a></div>';
$('.content').append(html);
i++;
});
});
};
Run Code Online (Sandbox Code Playgroud)
任何投入将不胜感激!!谢谢
我在IE中试过这个,它运行正常.
$(document).ready(function() {
$.get('http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id=0',
'xml' , function(data) {
alert(data);
});
});
Run Code Online (Sandbox Code Playgroud)
由于跨站点脚本问题,这在其他浏览器中不起作用.上述代码仅在其所在的页面位于同一域中时才有效.所以,你有很多选择,但没有一个是标准的.最好是从您的域中对URL进行ajax调用,然后从那里调用feed url; 从服务器端.有关详细信息,请参阅 https://stackoverflow.com/search?q=calling+webservice+from+another+domain+using+jquery