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、透视私人局"哈糖大菠萝有挂吗"详细辅助爆料教程(俱乐部辅助器攻略)。2、哈糖大菠萝有挂吗透视辅助...
透视插件"wepok... 1、透视插件"wepoker透视底牌脚本"详细辅助微扑克教程(有辅助功能透视)。2、wepoker透...
透视总结"wepok... 透视总结"wepoker买钻石有用吗"详细辅助德州论坛(辅助器安装包透视);玩家必备必赢加哟《136...
透视透视"hh po... 透视透视"hh poker软件"详细辅助AI教程(辅助器方法)1、许多玩家不知道hh poker软件...
透视最新"wpk私人... 透视最新"wpk私人辅助"详细辅助透明挂教程(破解版内购技巧);支持2-10人实时对战,虚拟庄家发牌...
透视私人局"wepo... 透视私人局"wepoker透视功能下载"详细辅助玩家教你(私人局透视插件辅助);玩家必备必赢加哟《1...
透视有挂"约局吧开挂... 此外,数据分析德州(约局吧开挂神器是真的吗)辅助神器app还具备辅助透视行为开挂功能,通过对客户约局...
透视透视"wepok... 透视透视"wepoker破解版内购"详细辅助新2025版(如何设置透视攻略)1、许多玩家不知道wep...
透视ai代打"pok... 透视ai代打"pokemmo脚本辅助器"详细辅助必胜教程(私人局有透视神器),支持语音通讯、好友开房...
透视游戏"wepok... 透视游戏"wepoker私人辅助器"详细辅助插件教程(模拟器哪个教程)这是由厦门游乐互动科技有限公司...