[Javascript] XMLHTTP send and receive stumper
Matt Warden
mwarden at gmail.com
Tue Nov 8 08:00:06 CST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ryan Cannon wrote:
> Greetings,
>
> I'm attempting to use XML HTTP to send and receive XML data, and then
> append the results to an XHTML page. Essentially I want to use the
> following class (or similar):
>
> function Feed(name,url) {
> this.name=name;
> this.url=url;
> this.status=0;
> this.xml=null;
> this.html=null;
> this.load=function () {
> loading=true;
> loadXMLDoc(this.url,"GET",null);
> this.status=1;
> }
> }
>
> Feed.load() will download the appropriate url, and save it's
> responseText in Feed.xml. the xmlhttp object will be dumped and re-
> initialized, sending Feed.xml as a post variable to my XSLT processor,
> which translates the XML into XHTML. This resultXML will be stored in
> Feed.html, and later appended to the page.
>
> 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)" ...]
responseXML refers to an XML DOM document.
for (var i=0; i<xmlhttp.responseXML.children.length; i++) {
body.appendChild(xmlhttp.responseXML.children[i]);
}
- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDcK9mrI3LObhzHRMRAkb8AKDjC0SLH/Uhlge/6y5smvh5PdoyOQCfau3H
oAcDai3jlNgGUeKBPIdekns=
=d5Up
-----END PGP SIGNATURE-----
More information about the Javascript
mailing list