我想從基於Web的PHP腳本http://fb.mobilechilli.com/chilli_news_reviews/news_feed_retrival.php中檢索一個動態生成的XML文件,該腳本返回一個XML文件。Jquery PHP驅動的XML請求
我試過使用Ajax Get
請求,但只是收到一個解析錯誤,我猜是因爲它試圖加載的頁面最初不是XML - 只有返回的響應?
我一直在瞎搞用了一段時間 - 這是目前我的測試代碼來查看錯誤:
//Get XML feed from the website and parse
$.ajax({
type: "POST",
url: "http://fb.mobilechilli.com/chilli_news_reviews /news_feed_retrival.php",
dataType:"xml",
success: done,
error:errorFun
});
});
function done(a,b,c) {
alert(a); alert(b); alert(c);
$(xml).find("NewsML").each(function()
{
alert("got this far");
var title = $(this).find('HeadLine').text();
alert(title);
});
}
function errorFun(a,b,c) {
alert(a);alert(b);alert(c);
alert("didnt work");
}
如果我剝從http://fb.mobilechilli.com/chilli_news_reviews/news_feed_retrival.php返回源的XML,並將其保存爲XML ,它工作正常,所以我不知道如何解決這個問題。
解析錯誤?請發佈一些代碼,響應示例,XML等。如果您需要幫助,則需要提供更多信息。 –