function showMsg(){ var xmlDoc=xmlHttp.responseXML.documentElement;//以xml文档的格式接收服务器的返回信息 var text=xmlDoc.getElementsByTagName("item")[0].nodeValue; alert(text); }这个是js里的ajax 的一个接收服务器返回值的处理函数,其他的创建xmlHttp什么的都没错,就这个函数接收服务器返回的<body> <item>ok </item> </body>时报错
var xmlDoc=xmlHttp.responseXML; var text=xmlDoc.getElementsByTagName("item")[0].nodeValue;
var xmlObj = xmlHttp.responseXML; var text=xmlObj.getElementsByTagName("item")[0].firstChild.nodeValue; document.getElementById ("myTime").innerHTML = text; <?php header("Content-Type: application/xml"); echo "<body><item>ok</item></body>"; ?>
header("Content-Type: application/xml");
按照楼上的方法我加上了header,好像还是不行,郁闷!继续在线等待....
var xmlDoc=xmlHttp.responseXML.documentElement;//以xml文档的格式接收服务器的返回信息
var text=xmlDoc.getElementsByTagName("item")[0].nodeValue;
alert(text);
}这个是js里的ajax 的一个接收服务器返回值的处理函数,其他的创建xmlHttp什么的都没错,就这个函数接收服务器返回的<body> <item>ok </item> </body>时报错
var text=xmlDoc.getElementsByTagName("item")[0].nodeValue;
var xmlObj = xmlHttp.responseXML;
var text=xmlObj.getElementsByTagName("item")[0].firstChild.nodeValue;
document.getElementById ("myTime").innerHTML = text;
<?php
header("Content-Type: application/xml");
echo "<body><item>ok</item></body>";
?>