Arun wrote:
I am trying to build a site using xmlhttprequest, so that the browser
never reloads. I want to pass the HTML info of the "navigation column"
, "content column" as a XML page from the server.
From the help on the net, I have managed to use xmlhhtprequest
succesfully to get the file from server and parse the XML. But I dont
know how to display the HTML info on the page.
When I just add the parsed HTML content from the xml to a <div>, it
just displays the text as HTML but not with the formating. ie the
display i get is " < b >this has to be in bold </ b > "
Judging from that description it sounds as if you are best served with a
library taking care of that stuff so you might want to look into
libraries like Sarissa
<http://sarissa.sourceforge.net/>
As for your problem you haven't provided any code so I can only guess
that you are using the responseText you receive but then try to add it
to an element as a text node e.g.
someElement.appendChild(document.createTextNode(ht tpRequest.responseText));
as that way you simply create a text node and any markup in responseText
shows up as plain text.
If the responseText contains HTML markup then one rather easy and rather
cross browser way of having it parsed and inserted into the document is
setting the innerHTML property of an element e.g.
someElement.innerHTML = httpRequest.responseText;
If you don't have an element then you can create one e.g.
var div = document.createElement('div');
div.innerHTML = httpRequest.responseText;
document.body.appendChild(div);
There are other ways, at least with Mozilla and with Opera it makes
sense to send XHTML and then simply import nodes from responseXML
instead of using responseText.
--
Martin Honnen
http://JavaScript.FAQTs.com/