[Javascript] TextNodes

Tom Allison tallison at tacocat.net
Thu Mar 30 15:52:36 CST 2006


On 3/29/2006, "Vicente Gallur Valero" <vicente at vgcomunicacion.com>
wrote:

>
>>
>> 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.
>

OK, I didn't get to the innerHTML method yet.
I'll have to give that a go.  Thank you.



More information about the Javascript mailing list