I want to retrieve a dynamically generated XML file from a web-based PHP script http://fb.mobilechilli.com/chilli_news_reviews/news_feed_retrival.php, this script returns an XML file.
I have tried using the Ajax Get
request but just receive a parse error, I guess because the page it's trying to load isn't initially XML - only the returned re开发者_开发百科sponse?
I've been messing around with it for a while - this is currently my test code to view the errors:
//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");
}
If I strip the XML from the returned source of http://fb.mobilechilli.com/chilli_news_reviews/news_feed_retrival.php and save it as XML, it works fine so I've no idea how to solve this.
maybe you have to tell the browser what kind of content your sending, by specifying the proper header content type. at the top of the document you should generate something like this:
<?php header("Content-type: application/xhtml+xml"); ?>
or this
<?php header("Content-Type:text/xml"); ?>
精彩评论