Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Re: XMLHTTP send and receive stumper
- From: liorean at gmail.com (liorean)
- Subject: [Javascript] Re: XMLHTTP send and receive stumper
- Date: Wed Nov 9 13:12:29 2005
On 09/11/05, Ryan Cannon <ryan@xxxxxxxxxxxxxx> wrote: > xmlhttp.responseXML.firstChild is not a document node (which we are > used to working with), but a document type node. The differences were > a little too subtle for me to wrap my head around quickly, but you > can test this by doing Isn't responseXML actually that reference to the Document node that you thought responseXML.firstChild was? > The correct way to access the document node (hence gaining access to > (document object functions) is > > xmlhttp.responseXML.documentElement No, that's not a reference to the Document node. That's a reference to the root Element node of the document. The ownerDocument property of the nodes in the document should point to the Document node. > > Everything seemed to be going swimmingly, until I try to append the > > result. body.innerHTML+=xmlhttp.responseText works fine, but > > body.appendChild(xmlhttp.responseXML) causes the following error in > > Firefox: > > > > Error: [Exception... "Node cannot be inserted at the specified > > point in the hierarchy" code: "3" nsresult: "0x80530003 > > (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" ...] > > > > I obviously don't want to use innerHTML since everything I'm doing > > is in XML, but I haven't been able to find a good way to debug this > > error. Also, there's some other browser-compatibility errors, so if > > anyone could point to a good tutorial on sending XML and processing > > an XML response with javascript, I'd appreciate it. Elements are created within a document realm. Elements can't be moved between different documents arbitrarily, they need to be imported to another document. At least, that's how it works in a more compliant user agent. To import a node in these user agents you need to use the importNode method of the Document node. As I recall iew doesn't support importing nodes, but is not as strict on this front and allows workarounds instead. -- David "liorean" Andersson <uri:http://liorean.web-graphics.com/>
- References:
- [Javascript] XMLHTTP send and receive stumper
- From: Ryan Cannon
- [Javascript] Re: XMLHTTP send and receive stumper
- From: Ryan Cannon
- [Javascript] XMLHTTP send and receive stumper
- Prev by Date: [Javascript] Re: XMLHTTP send and receive stumper
- Next by Date: [Javascript] display text based on co-ordinates on image
- Previous by thread: [Javascript] Re: XMLHTTP send and receive stumper
- Next by thread: [Javascript] display text based on co-ordinates on image
- Index(es):