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

相关内容

热门资讯

透视游戏!哈糖大菠萝开挂(透视... 透视游戏!哈糖大菠萝开挂(透视)2025新版技巧(2026已更新)(哔哩哔哩);1、完成哈糖大菠萝开...
透视数据!aapoker如何设... 透视数据!aapoker如何设置胜率(透视)透视脚本入口(一贯真的有挂);1、游戏颠覆性的策略玩法,...
透视辅助!智星德州插件2024... 透视辅助!智星德州插件2024最新版(透视)介绍教程(2025已更新)(哔哩哔哩)1、进入游戏-大厅...
透视能赢!aapoker辅助软... 透视能赢!aapoker辅助软件合法吗(透视)辅助插件工具(果然真的有挂)1、在aapoker辅助软...
透视黑科技!epoker免费透... 透视黑科技!epoker免费透视脚本(透视)技巧教程(2026已更新)(哔哩哔哩)1、任何epoke...
透视有挂!aapoker辅助怎... 透视有挂!aapoker辅助怎么用(透视)发牌逻辑(确实存在有挂)1、游戏颠覆性的策略玩法,独创攻略...
透视总结!大菠萝免费辅助(透视... 透视总结!大菠萝免费辅助(透视)黑科技教程(2022已更新)(哔哩哔哩)1、在大菠萝免费辅助ai机器...
透视辅助!aapoker辅助怎... 透视辅助!aapoker辅助怎么用(透视)透视方法(原来有挂);一、aapoker辅助怎么用AI软件...
透视规律!werplan免费挂... 透视规律!werplan免费挂下载(透视)可靠教程(2022已更新)(哔哩哔哩)1.werplan免...
辅助透视!aapoker透视脚... 辅助透视!aapoker透视脚本下载(透视)真的假的(竟然真的是有挂)1、aapoker透视脚本下载...