更新:2007 年 11 月
停止由执行器发出的、挂起的网络请求。
MyExecutor.abort();
备注
中止请求的具体情况会因实现执行器的方式不同而变化。但是,从 WebRequestExecutor 派生的所有执行器都必须将其状态设置为中止,且必须引发关联 Sys.Net.WebRequest 对象的已完成事件。
说明: |
|---|
在已调用 abort 后,执行器属性包含不一致的数据。 |
示例
下面的示例演示如何使用默认的 Sys.Net.XMLHttpExecutor 类中止请求。
// 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);
}
说明: