Mul*_*gno 12 javascript rss jquery
我正在尝试使用jQuery从MailChimp RSS提要中提取标题和描述.
我正在尝试:
$.ajax({
type: 'GET',
url: 'http://us10.campaign-archive1.com/feed?u=21a65076da97205b5e5ff33e6&id=cc8bfc765e',
crossDomain: true,
dataType: 'jsonp',
success: function (xml) {
$(xml).find("item").each(function () {
var title = $(this).find("title").text();
var description = $(this).find("description").text();
var linkUrl = $(this).find("link_url").text();
var link = "<a href='" + linkUrl + "' target='_blank'>Read More<a>";
$('#feedContainer').append('<article><h3>' + title + '</h3><p>' + description + link + '</p>');
});
}
});
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
Uncaught SyntaxError: Unexpected token < on
http://us10.campaign-archive1.com/feed?u=21a65076da97205b5e5ff33e6&id=cc8bfc765e&callback=jQuery214010618008393794298_1436280190025&_=1436280190026
Run Code Online (Sandbox Code Playgroud)
如果通过jQuery无法实现,还有另一种方法吗?我尝试使用Yahoo Developer Console但robots.txt禁止访问..
似乎mailchimp禁止访问不是来自浏览器,我试图卷曲URL,我得到404没有找到.
在使用 jquery 查询之前需要解析 XML ( https://api.jquery.com/jQuery.parseXML )
var xmlDoc = $.parseXML(xml);
var $xml = $(xmlDoc);
$xml.find("item");
Run Code Online (Sandbox Code Playgroud)将有效数据类型设置为xml
| 归档时间: |
|
| 查看次数: |
336 次 |
| 最近记录: |