Compartilhar via


abort Method (IXMLHTTPRequest)

 

Cancels the current HTTP request.

JScript Syntax

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()">  

Visual Basic Syntax

oXMLHttpRequest.abort  

C/C++ Syntax

HRESULT abort(void);  

Return Values

S_OK
The value returned if successful.

Remarks

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

Versioning

Implemented in: MSXML 3.0 and MSXML 6.0

Applies to

IXMLHTTPRequest

See Also

readyState Property (IXMLHTTPRequest)
open Method (IXMLHTTPRequest)