Jump to content


Photo

Ajax: HTML in responseXML: Dynamic HTML Content


  • Please log in to reply
No replies to this topic

#1 Charlie.

Charlie.
  • New Members
  • Pip
  • Newbie
  • 4 posts
  • LocationPort Elizabeth, South Africa

Posted 05 May 2006 - 07:01 AM

Consider the following:

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

<xhtml>
<form...
...
</form>
...
</xhtml>

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!
Why the Penguins Won - [a href="http://blue-wildebeest.blogspot.com" target="_blank"]http://blue-wildebeest.blogspot.com[/a]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users