Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.Net.WebRequestExecutor abort Method

Stops the pending network request issued by the executor.

Syntax

MyExecutor.abort();

Return Value

Remarks

The specifics of aborting a request vary depending on how an executor is implemented. However, all executors that derive from WebRequestExecutor must set their state to aborted and must raise the completed event of the associated Sys.Net.WebRequest object.

note

The executor properties do not contain consistent data after abort has been called.

Example

The following example shows how to abort a request using the default Sys.Net.XMLHttpExecutor class.

JavaScript

// This function aborts a Web request.
function AbortWebRequest()
{
    // Create the WebRequest object.
    wRequest =  new Sys.Net.WebRequest();

    // Set the request Url.  
    wRequest.set_url("getTarget.htm");

   // Clear the results area.
    resultElementId.innerHTML = "";

    // Set the Completed event handler, 
    // for processing return data
    wRequest.add_completed(OnCompleted);

    // Make the request.
    wRequest.invoke();

    // Get the current executor.
    var executor = wRequest.get_executor();


    // Abort the request.
    executor.abort();

    // Check if the executor is aborted.
    var execAborted = 
        executor.get_aborted();

    alert("Executor aborted: " + execAborted);
}