Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Error removing and appending Node

Status
Not open for further replies.

caesarkim

Programmer
Oct 30, 2003
56
US
I am trying to replace the current node with an updated node. But when I try to replace a node, I get "Cannot mix different threading models in document" in "insertBefore" function call. I tried "replaceChild" and "appendChild". But I got the same javascript error.

I have no idea why it is happening. Is it because of thread conflicts? Is there anybody who knows why and how to fix the following code? I'd really appreciated it.


var editedNode = getXML("get_new.do?sid="+sid);
var updatedDsource = new DataSource("UPDATED_NODE",editedNode);


var allDOM = dsource.getDocument(whole_dom);
var allDocument = allDOM.documentElement;
var total = allDocument.childNodes.length;

var currentNode = allDocument.selectSingleNode("//newItems/item[@id='"+sid+"']");


allDOM.documentElement.removeChild(currentNode);
var msgs = allDocument.childNodes;
var msg = msgs.item(0);

allDOM.documentElement.insertBefore(editDOM.documentElement,msg);



 
oh. sorry.. here it is.

var dsource = new DataSource("DISPLAY",getXML("display.xsl");

getXML function is just grabbing a XML through HTTP.


function DataSource(name, xmlObj)
{
this.screenshots = {};
this.dataSrc = null;
this.docXML = null;

this.load = function(dName, dObj)
{
this.screenshots[dName] = dObj;
this.docXML = dObj;
}

this.getDocument = function(dName)
{
//return this.screenshots[dName];
return this.docXML;
}

this.load(name, xmlObj);

this.merge = function(datasrc)
{
var msgs = datasrc.docXML.documentElement.childNodes;
for (var i=0; i<msgs.length; i++)
{
var msg = msgs.item(i);
this.docXML.documentElement.appendChild(msg);
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top