Jump to content


This topic is now archived and is closed to further replies.


Ajax: HTML in responseXML: Dynamic HTML Content

Recommended Posts

Consider the following:

I have a PHP script on the server that generates an HTML form. It wraps it in XML, like so:


This is done because, strictly speaking, XML documents should only have one root node and my application's design states that this script will return well-formed XML. There may be more than just a form element in the response.

I have a javascript function that uses Ajax to GET this. The code that fetches it is nothing special. Once it returns, I have a response object with two properties: responseText and responseXML. Looking at responseText shows that the Ajax code works perfectly and does get the correct XML back. Using getElementsByTagName('xhtml'), I can get the xhtml element successfully. Now, I want to insert ALL the HTML within that element into a conveniently prepared DIV element on my page. How do I do this?

I know that IE would allow me to set the "innerHTML" property of my DIV to the "xml" property of my xhtml node, but the "xml" property is not supported by other browsers, so that does not help. (My reference browser is Firefox, BTW)

Please help!

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.