Sign In/My Account | View Cart  
advertisement

Article:
 Very Dynamic Web Interfaces
Subject: Problem
Date: 2005-03-24 14:35:49
From: Goonie

I'd like to load an XML/HTML fragment from the server and replace a node in the document by that fragment. That way, I could periodically refresh a specific region of the page.


Here is what I'm doing in the readyStateChange handler:


e = document.getElementById('fragment');
e.parentNode.replaceChild(req.responseXML.firstChild, e);


Unfortunately, an XML fragment that is fetched via XMLHttpRequest is not accepted as valid HTML by Gecko/Firefox: It only shows up as text-only, without any formatting. What's worse, getElementById() does not locate my fragment after it has been replaced once.


Is it possible to convert an XML node to an HTML element/node before insertion into the DOM?


Are there any good books on the matter that go well beyond this article?


Regards,


Andreas


Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • Problem
    2005-04-07 23:21:31 rkhlin

    Wondering anyone knows how to solve this:
    When I made a XMLHttpRequest, the returning HTML not only have HTML also some javascript functions. However the Caller page don't seem to understand the new javascript functions have been loaded in. So is there anyway we can force the Caller to understand the new javascript functions???

  • Problem
    2005-04-06 23:00:56 mdchaney

    <blockquote>I'd like to load an XML/HTML fragment from the server and replace a node in the document by that fragment. That way, I could periodically refresh a specific region of the page.</blockquote>


    Use the "responseText" attribute to get at the html as text. Then use "innerHTML" to place it where you want it.


    If you don't need HTML, but you're just putting text in, you might also use the simple DOM methods to create a text node, stick it on a paragraph, then put the paragraph where you want it. Put your replaceable text in a div with a unique id so you can find it easily, clean it out and change the text.


Sponsored By: