返回由于白名单安全我使用PHP脚本来从外部服务器返回的XML。使用jQuery解析XML从PHP文件
PHP文件代码如下 -
<?php
include_once 'utilityCurl.class.php';
$uri = 'http://OURSERVER/feeds/?feedID=99&c';
$response = utilityCurl::fetchContent($uri);
echo $response;
它使用卷曲返回的XML文件。
然后我用一个jQuery AJAX XML脚本解析 -
$.ajax({
type: "GET",
url: "http://fb.mobilechilli.com/chilli_news_reviews/news_feed_retrival.php",
dataType: "xml",
success: parseXml,
error: errorMsg
});
//Once xml parsed and entered onto page - run caroufred class that makes the carousel work.
function parseXml(xml)
{
$(xml).find("NewsItem").each(function()
{
var title = $(this).find('HeadLine').text();
var artist = $(this).find('NewsLineType').text();
var listItem = $('<p>hello '+title+'</p><p>'+artist+'</p><br/>');
$(".newsHeader").append(listItem);
});
alert("yep");
}
function errorMsg() {
alert("error getting xml feed");
}
});
不幸的是我只是得到显示错误消息!
任何人可以建议在那里我锣错了吗?
感谢 保罗
填充你得到在Firebug控制台的任何错误? – Dogbert
没有恼人的不是 - firebug状态一切都好! – Dancer
它是否显示请求正在发出,以及正确的响应? – Dogbert