开发者

Parsing responseXML via AJAX POST

开发者 https://www.devze.com 2022-12-14 14:20 出处:网络
I\'m trying to develop a small AJAX program. XML I get from the server in responseXML. <?xml version=\"1.0\"?>

I'm trying to develop a small AJAX program.

XML I get from the server in responseXML.

<?xml version="1.0"?>
<serverResponse><resultaat>1</resultaat></serverResponse&开发者_如何学JAVAgt;

If I try to retrieve the "resultaat" node and its content using this code :

var serverResponse = mailObject.responseXML;
var resultaatXML = serverResponse.getElementsByTagName("resultaat");
alert(resultaatXML[0].childNodes[0].nodeValue);

Firefox alerts 1 And Internet Explorer alerts 'undefined'.

I'm really stuck at this. Can someone help?

Thx


Loading that XML into MSXML the code works fine. Try adding:-

alert(serverResponse.xml);

to see exactly what IE thinks is contained in the XML Document.


Check out this question. Basically, IE requires doesn't automatically parse the XML, you have to explicitly tell it to. See this article for more.

0

精彩评论

暂无评论...
验证码 换一张
取 消