ASP.NET请求超时,从jQuery调用ASMX中的异步Web方法
创始人
2024-11-12 06:00:24
0

将Async="true"添加到ASMX中的Web方法,并在jQuery Ajax请求中添加async: true选项。

示例代码:

ASMX中的Web方法:

[WebMethod] [ScriptMethod(UseHttpGet = true)] public void MyWebMethod(string param1) { // Some code here }

更改为异步方法:

[WebMethod] [ScriptMethod(UseHttpGet = true, Async = true)] public IAsyncResult BeginMyWebMethod(string param1, AsyncCallback callback, object asyncState) { // Some code here }

[WebMethod] [ScriptMethod(UseHttpGet = true, Async = true)] public void EndMyWebMethod(IAsyncResult result) { // Some code here }

在jQuery中添加async选项:

$.ajax({ url: "MyWebService.asmx/MyWebMethod", data: { param1: "value1" }, type: "GET", contentType: "application/json; charset=utf-8", dataType: "json", async: true, success: function (response) { // Some code here }, error: function (xhr, textStatus, errorThrown) { // Some code here } });

相关内容

热门资讯

透视了解!aapoker怎么提... 透视了解!aapoker怎么提高中牌率(透视)插件(确实存在有挂);1、完成aapoker怎么提高中...
透视好友房!aapoker插件... 透视好友房!aapoker插件下载(透视)透视软件(一贯是有挂)小薇(透视辅助)致您一封信;亲爱aa...
透视最新!aapoker怎么开... 透视最新!aapoker怎么开辅助器(透视)ai插件(好像有挂);1、用户打开应用后不用登录就可以直...
透视透视!aapoker辅助怎... 透视透视!aapoker辅助怎么用(透视)发牌逻辑(竟然是真的有挂)1、打开软件启动之后找到中间准星...
透视辅助!aapoker能控制... 透视辅助!aapoker能控制牌吗(透视)免费透视脚本(好像真的有挂);1、aapoker能控制牌吗...
透视透视!aapoker破解侠... 透视透视!aapoker破解侠是真的吗(透视)免费透视脚本(原来真的是有挂);运aapoker破解侠...
透视攻略!aapoker真的假... 透视攻略!aapoker真的假的(透视)ai插件(确实有挂)aapoker真的假的辅助器中分为三种模...
透视教程!aapoker透视插... 透视教程!aapoker透视插件(透视)透视脚本(果然真的是有挂)1、超多福利:超高返利,海量正版游...
透视有挂!aapoker辅助软... 透视有挂!aapoker辅助软件合法吗(透视)发牌逻辑(总是是真的有挂)一、aapoker辅助软件合...
透视苹果版!aapoker a... 透视苹果版!aapoker ai插件(透视)透视脚本下载(一直存在有挂);1、超多福利:超高返利,海...