Content-type:text / xml返回null responseXML,尽管responseText返回有效

时间:2011-07-19 23:42:21

标签: php javascript xml ajax content-type

PHP代码:

<?php

include('SQLparseQuery.php');
include('queryToXML.php');
$rows = array('code', 'name', 'price', 'description');
$filter = array("", "featured='1'");
$coffeeList = getFromSQL('*', 'coffees', $rows, $params=$filter); //Retrieves only featured coffees from SQL
makeXML($coffeeList, $rows, "coffee", "featuredCoffees", true); //writes featuredCoffees.xml

header('Content-type: text/xml');
echo file_get_contents("../xml/featuredCoffees.xml");

?>

Ajax电话:

function featuredInteraction() {
        if (request.readyState==4) {
                if (request.status==200) {
                        alert(request.responseXML);
                }
        }
}

A link to the XML document.

request.responseXML返回Null。 request.responseText返回XML。

我发现的一切都说问题是:header(“Content-type:text / xml”);缺少了,但事实并非如此。它就在那里。如果直接转到XML文档,XML文档会在浏览器中正确呈现。

我不知道问题是什么。帮助真的很棒。

编辑:我想我应该补充一点,我有一个类似的脚本,在网站上没有任何缺陷。为什么这一个是残酷和不寻常的完全超出我的范围。

0 个答案:

没有答案