Sys.Net.WebRequestExecutor executeRequest Method

Instructs the executor to execute a Web request.

MyExecutor.executeRequest();

Remarks

When this method is called, the executor packages the content of the Web request instance and initiates processing.

This method is intended to be used by a custom executor. If you are implementing a custom executor, you instantiate the executor, assign it to the Web request instance, and then invoke the method on the executor instance.

The main phases of an executor life cycle that pertain to the executeRequest method are as follows:

  • The executor is created and initialized.

  • The executeRequest is called, which performs the following:

    • Sets up the specifics of a network call or some other processing.

    • Assigns an event handler to the request object.

    • Sets up the background time-out loop or time-out watcher.

    • Makes an asynchronous call to the browser's XmlHttpRequest implementation to dispatch the request to the server.

An executor instance is in memory while the request progresses asynchronously on the server. The request finishes in one of the following ways:

  • The executor sets its state to complete and raises the completed event of the associated WebRequest object.

  • The executor sets its state to timedout and raises the completed event of the associated WebRequest object.

  • The executor sets its state to aborted and raises the completed event of the associated WebRequest object.

At this point the executor is no longer needed and you can discard it by calling its dispose method.

Example

The following example shows how to make a Web request using the executeRequest method.

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

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


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

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

    // To use executeRequest you must instantiate the
    // executor, assign it to the Web request instance,
    // then call the executeRequest function.
    // Note: Normally to make a Web request you use
    // the invoke method of the WebRequest instance.
    var executor = new Sys.Net.XMLHttpExecutor();
    wRequest.set_executor(executor); 
    executor.executeRequest();

    var started = executor.get_started();

    alert("Executor started: " + started);
}

See Also

Reference

Sys.Net.WebRequestManager Class

Sys.Net.WebRequest Class

Sys.Net.XMLHttpExecutor Class