Jump to content

Ajax: HTML in responseXML: Dynamic HTML Content


Charlie.

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:

<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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.