[Javascript] XMLHTTP send and receive stumper

Ryan Cannon ryan at ryancannon.com
Tue Nov 8 07:42:12 CST 2005


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)" ...]

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.

Cheers,
-- 
Ryan Cannon

Wordslinger, Webwright
http://RyanCannon.com






More information about the Javascript mailing list