Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get responseXML to work in my AJAX?

Status
Not open for further replies.

deadpool42

Programmer
May 24, 2004
40
0
0
I've been using the responseText property in my AJAX, but I decided to switch over to sending XML and now it doesn't work.

This Javascript:
Code:
alert(agent.handler.responseXML.documentElement.getElementsByTagName('test')[0]);
says undefined, but if I remove the [0], it says object HTMLcollection.

responseXML and documentElement both seem to be defined, so I'm assuming the XML is right. Here's the PHP that generates it:

Code:
header('Content-type: text/xml'); 
echo '<?xml version="1.0" encoding="ISO-8859-1"?><test><![CDATA[this is the content]]></test>';
 
There's a whole separate forum for a specific part of Javascript? Seems a little odd to me, but thanks for the link.
 
Aside from the fact that AJAX is a misnomer (it isn't necessarily asynchronous and it doesn't necessarily return XML), the AJAX forum addresses all issues associtated with "calling a server program from a browser client". This includes subjects such as how to return data to the client, and in what format (JSON vs text vs HTML) that use PHP, VBScript or some other server-side language, and design considerations that are independent of language. There IS more to "AJAX" than just javascript.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
tsuji considers it a bad word in ANY culture. Don't get him started on why. We've kinda agreed to disagree about the whole subject.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
You're just TRYING to start something, aren't you! [hammer]

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
To: op
I have seen you do not get satisfaction from the suggested forum till now. Nonetheless, I can offer this piece of hint, if and only if your responseXML is what expected.

>alert(agent.handler.responseXML.documentElement.getElementsByTagName('test')[0]);
[tt]alert(agent.handler.responseXML.getElementsByTagName('test')[0].text);[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top