我想通过jquery ajax获取rss提要,但每次这样做时,我都会得到一个解析器错误。我的feed相对比较复杂(使用cdata和自定义名称空间),因此我尝试剥离返回的文档(以及一百万个其他组合),但即使是一个非常简单的文档,它仍然失败。这是我的ajax代码:
$.ajax({
type: 'GET',
url: ...,
dataType: 'xml',
success: function(xml) {
...
},
error: function(xhr, textStatus, error) {
console.log('status: ' + textStatus);
console.log(xhr.responseText);
showError('an unknown error occurred while trying to fetch the feed: ' + xhr.status);
}
});
控制台输出:
status: parsererror
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>title</title>
<link>link</link>
<description>desc</description>
<lastBuildDate>build date</lastBuildDate>
<generator>gen</generator>
</channel>
</rss>