jQuery XML解析错误
问题描述:
我想为我的网站编写一个简单的RSS解析器。虽然我得到错误jQuery XML解析错误
XML Parsing Error: no element found Location: moz-nullprincipal:{85891b5c-0ab8-4b89-92ba-bdef3e044891} Line Number 1, Column 1:
这个错误是什么意思?
$(function() {
var rssUrl = "http://www.guardian.co.uk/energy-saving-trust/rss";
$.get(rssUrl, function(data) {
var $xml = $(data);
$xml.find("item").each(function() {
var $this = $(this),
item = {
title: $this.find("title").text(),
link: $this.find("link").text(),
description: $this.find("description").text(),
pubDate: $this.find("pubDate").text(),
author: $this.find("author").text()
}
alert('got here');
});
});
});
答
,看起来像一个跨域调用你有一个撑着什么,允许什么?
编辑!离开的方法的一些示例阅读RSS跨域
有你的服务器代理内容
或使用libary和服务像
是的,我想嵌入Guardian RSS feed int我的网站。我不知道我需要使用一个插件,如果它不在同一个域上 –
的方式来获取RSS源跨域。 OBS!通过插件我的意思是jquery插件不是浏览器的一个 – megakorre
当然是设法使用http://www.zazar.net/developers/jquery/zrssfeed/ –