...

View Full Version : XmlHttprequest bug in IE



Ravenn
09-20-2005, 07:52 PM
I have a page that uses XmlHttpRequest to populate a dynamic tree. When the tree is opened with initial directory as a parameter, it's sorta calling itself to open itself down to that folder.
I don't have the code but I'll outline it; it's nothing special.
I have a logging facility and I will post the long to explain the error. And yes the response handler checks for the stare being 4 and for status 200 too.
So it's like that; XmlHttp is in one global variable.


CallHttpRequest(Folder)
{
log(call,Folder); asynchandler = function() { Handler(Folder) }; send(url?f=Forder);
}

Handler(Folder)
{
if (check stuff) { log(hndstart,Folder); MainFunction(Folder); log(hndend,Folder);
}

MainFunction(Folder)
{
...do stuff; CallHttpRequest(AnotherFolder);
//so, the next request is sent in the handler of the previous one
}

Here's the log I always get


sending request for TreeLoader.aspx
handler fired null
sending request for TreeLoader.aspx?Folder=1
handler ended null
handler fired 1
sending request for TreeLoader.aspx?Folder=1\2
handler ended 1
handler fired 1\2
handler ended 1\2
handler fired 1\2
handler ended 1\2

Why doesthe response for 1\2 tirgger handler two times? I only send one request!

KC-Luck
09-21-2005, 05:22 PM
you may get better response if you reveal a bit more of your code, this is very hard to debug with the provided amount of information. :(

Ravenn
10-06-2005, 10:58 AM
Here's the version of the code with all the fat trimmed.


var domObj = new ActiveXObject("Microsoft.XMLDOM");
var httpObj = new ActiveXObject("Microsoft.XMLHTTP");
var treeNodeGlobal;

function send(treeNodeDiv, sTarget)
{
httpObj.Open("POST", sTarget, true, "", "");
httpObj.Send ("");
treeNodeGlobal = treeNodeDiv;
httpObj.onreadystatechange = httpReqDone;
}

function httpReqDone()
{
if (httpObj.readyState == 4)
{
if (httpObj.status == 200)
{
domObj.loadXML(httpObj.ResponseText);
if (treeNodeGlobal.getAttribute("isexpanded")!="true")
{
AppendChildren(domObj.xml, treeNodeGlobal);
}
}
}
}



function BuildTree(treeNodeDiv,noevent)
{
send(treeNodeDiv,"TreeLoader.aspx?Folder=" + escape(treeNodeDiv.getAttribute("fullpath")));

}


function AppendChildren(xmlChildren, treeNodeDiv)
{
var oDoc = new ActiveXObject("Microsoft.XMLDOM");
oDoc.loadXML(xmlChildren);
var RowLength = oDoc.getElementsByTagName("Row").length;
for (var iCnt=0;iCnt<RowLength;iCnt++)
{
if (initPath.indexOf(sFolderPath) >= 0)
{
BuildTree(oTmp,true);
}
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum