[Javascript] TextNodes
Vicente Gallur Valero
vicente at vgcomunicacion.com
Wed Mar 29 00:13:53 CST 2006
>
> I want to be able to pull from the server either a preformatted HTML
> string or a multiline string and insert it into the clients <div>
> segment.
>
> This I know presents some problems because the TextNode cannot, by
> definition, hold anything like a <b> or <p> tags. But I don't know
> enough of the alternatives to be able to sort this one out. Is there
> where responseXML takes precedence over the responseText method of the
> Request object?
>
> How do you use them?
>
I think the easiest way is take always the responseText property instead
of responseXML, even if you use (X)HTML code in your response. Then you
can insert the code into the <div> by asigning it to the innerHTML
property of the <div>. If it contains HTML code, it will be parsed by
the browser. This method will not work in an XHTML document served with
an XHTML Content-type header.
You can also use the responseXML property, but then you must ensure the
code is well formed XML and it's served with an XML Content-type header.
Then you can insert the code with the DOM methods.
--
Vicente Gallur Valero
http://www.vgcomunicacion.com
More information about the Javascript
mailing list