• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
works guo

成功的渴望与生俱来---- 成功是获得赞美与尊重的最有效的途径
博客园    首页    新随笔    联系   管理    订阅  订阅

值得关注的invoke Method

Sys.Net.WebRequest invoke Method          

执行Web请求
Sys.Net.WebRequestManager.invoke(WebRequest);

异常:
Sys.InvalidOperationException        最多只能调用一次

如果你已经注册completed request event handler为你的Sys.Net.WebRequest 实例,按照网络堆异步调用handler的请求过程.一个WebRequest实例中只能调用一个invoke.如果网络请求已经发出就会抛出一个异常.

怎样使用:

// This function sets an HTTP header for
//
 the Web request.
 function WebRequestHeader() 
 
{
    
// Instantiate the WebRequest object.
    var wRequest =  new Sys.Net.WebRequest();

    
// Set the request Url.  
    wRequest.set_url(postPage); 

    
// Set the request verb.
    wRequest.set_httpVerb("POST");

    
var body = "Message=Hello! Do you hear me?"
    wRequest.set_body(body);

    
// Set the value of the HTTP header's "Content-Length".
    wRequest.get_headers()["Content-Length"] = body.length;

    
// Set the web request completed event handler,
    // for processing return data.
    wRequest.add_completed(OnWebRequestCompletedHeader);

    
// Clear the results page element.
    GetElementById("ResultsId").innerHTML = "";

    
// Execute the request.
    wRequest.invoke();  
}




posted @ 2008-03-10 20:37  works guo  阅读(723)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3