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 } });

相关内容

热门资讯

事发当天!wepoker透视脚... 事发当天!wepoker透视脚本是什么(透视)一直有挂(有挂解惑开挂辅助安装)-哔哩哔哩1、首先打开...
突发!impoker辅助,po... 突发!impoker辅助,poker world辅助,方案教程(有挂工具)-哔哩哔哩一、poker ...
有玩家发现!newpoker脚... 有玩家发现!newpoker脚本(透视)原来真的有挂(有挂解惑开挂辅助辅助器)-哔哩哔哩1、首先打开...
记者获悉!wepoker怎么看... 您好,wepoker怎么看底牌这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054...
昨日!wepoker透视脚本(... 昨日!wepoker透视脚本(透视)其实确实有挂(真实有挂开挂辅助工具)-哔哩哔哩1、在wepoke...
为切实保障!wepoker透视... 为切实保障!wepoker透视有吗,pokerrrr2辅助,方针教程(有挂技术)-哔哩哔哩1、起透看...
为了进一步!hhpoker怎么... 为了进一步!hhpoker怎么破解(透视)原来是有挂(有挂方针开挂辅助下载)-哔哩哔哩1、完成hhp...
近日!智星菠萝透视,智星菠萝透... 近日!智星菠萝透视,智星菠萝透视,模板教程(有挂透明挂)-哔哩哔哩1、全新机制【智星菠萝透视软件透明...
截至目前!wepoker免费脚... 截至目前!wepoker免费脚本咨询(透视)原来有挂(有挂秘笈开挂辅助平台)-哔哩哔哩1、任何wep...
有了最新消息!xpoker辅助... 有了最新消息!xpoker辅助神器,wepoker怎么发冤家牌,策略教程(有挂教程)-哔哩哔哩1、在...