abort Method (IXMLHTTPRequest)

 

Cancels the current HTTP request.

oXMLHttpRequest.abort();  

Example

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>  
<!--  
  function XMLHTTPAbort_onclick() {  
    var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.6.0");  
    xmlhttp.onreadystatechange = doHttpReadyStateChange;  
    xmlhttp.open("GET", "http://<%=Request.ServerVariables("Server_Name")%>/sample.xml", true);  
    xmlhttp.send();  
    // alert(xmlhttp.responseXML.xml);  
  
    function doHttpReadyStateChange() {  
       switch (xmlhttp.readyState) {  
  
          // The following lines allow completion of the XMLHTTP request  
          // case 4: alert(xmlhttp.responseXML.xml);  
          // default: return;  
  
          // The following lines abort the XMLHTTP request  
          case 2: xmlhttp.abort();  
          default: alert(xmlhttp.responseXML.xml);  
       }  
    }  
  
}  
//>  
</SCRIPT>  
<INPUT type="button" value="Abort XMLHTTP" id=XMLHTTPAbort name=XMLHTTPAbort  
LANGUAGE=javascript onclick="return XMLHTTPAbort_onclick()">  

oXMLHttpRequest.abort  

HRESULT abort(void);  

Return Values

S_OK
The value returned if successful.

The request will be returned to the UNINITIALIZED state, and open method must be called next.

Implemented in: MSXML 3.0 and MSXML 6.0

IXMLHTTPRequest

readyState Property (IXMLHTTPRequest)
open Method (IXMLHTTPRequest)

Show: