Link to home
Create AccountLog in
Avatar of tonelm54
tonelm54

asked on

Cancel Microsoft.XMLDOM request

Good evening,
Ive managed to adopt some code to do exactly what I want, and its working fine, apart from one issue, When multiple calls are made they all seem to queue and then makes the application hang.

Is it possible to test the status of Microsoft.XMLHTTP, and if its waiting for a reply, cancel the request and start a new?


        var xmlHttp;
        function suggestText(objTextbox) {
       
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            xmlHttp.open("post", "WebService1.asmx/HelloWorld3", true);
            xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
           
            xmlHttp.onreadystatechange = doUpdate;
            xmlHttp.send("strName=" + encodeToHex(objTextbox.value));

            return false;
        }

        function doUpdate() {
            if (xmlHttp.readyState == 4) {
                xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async = "false";
                xmlDoc.loadXML(xmlHttp.responseText);

                document.getElementById('lisAutoSuggest').innerHTML = xmlDoc.getElementsByTagName("strName")[0].childNodes[0].nodeValue;
            }
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Proculopsis
Proculopsis

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account