Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XmlHttprequest bug in IE

    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.
    Code:
    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
    Code:
    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!

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder
    Join Date
    Jul 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's the version of the code with all the fat trimmed.
    Code:
    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);
    		}
    	}
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •