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

相关内容

热门资讯

最新消息!哈糖大菠萝可以开挂吗... 最新消息!哈糖大菠萝可以开挂吗,约局吧德州可以透视吗(透视)详细教程(有挂秘诀)-哔哩哔哩1、让任何...
透视真的!红龙poker辅助,... 透视真的!红龙poker辅助,wepoker私局辅助(透视)总结教程(有挂方式)-哔哩哔哩1、金币登...
在玩家背景下!wpk插件辅助,... 在玩家背景下!wpk插件辅助,哈糖大菠萝免费辅助器(透视)了解教程(今日头条)-哔哩哔哩1)哈糖大菠...
透视模拟器!拱趴大菠萝挂哪里,... 透视模拟器!拱趴大菠萝挂哪里,wepokerplus辅助(透视)详细教程(有挂方式)-哔哩哔哩透视模...
于此同时!拱趴大菠萝自动计算机... 于此同时!拱趴大菠萝自动计算机器人,wepoker透视脚本免费(透视)科普教程(真的有挂)-哔哩哔哩...
辅助透视!德州来玩辅助器,we... 辅助透视!德州来玩辅助器,wepoker透视辅助下载(透视)普及教程(有挂规律)-哔哩哔哩1.wep...
透视科技!德州hhpoker脚... 透视科技!德州hhpoker脚本,wepoker怎么开辅助(透视)科普教程(有挂教学)-哔哩哔哩1)...
相较于以往!聚星ai辅助工具激... 相较于以往!聚星ai辅助工具激活码,模拟器打开hhpoker(透视)了解教程(的确有挂)-哔哩哔哩1...
透视计算!wepoker底牌透... 透视计算!wepoker底牌透视,佛手在线是不是有挂(透视)详细教程(有挂解惑)-哔哩哔哩佛手在线是...
透视透视!wepoker-h5... 透视透视!wepoker-h5下载,约局吧德州可以透视吗(透视)必备教程(有挂教学)-哔哩哔哩透视透...