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真的假的,aapoker透视脚本,线上教程(有挂软件);最新版2024是一款...
今日百科!wepoker私人局... 今日百科!wepoker私人局开挂视频,wepoker辅助器如何使用,黑科技教程(有挂技巧)准备好在...
我来教教你!wpk作弊,hhp... 这是一款非常优秀的hhpoker作弊码怎么用 ia辅助检测软件,能够让你了解到hhpoker作弊码怎...
科技新动态!黑侠破解wepok... 1、科技新动态!黑侠破解wepoker,aapoker透视脚本入口,教你教程(有挂辅助);详细教程。...
专业讨论!wepoker挂,h... 专业讨论!wepoker挂,hhpoker是正规的吗,解说技巧(有挂辅助)准备好在hhpoker是正...
技术分享!hhpoker有没有... 技术分享!hhpoker有没有作弊辅助,wepoker免费脚本咨询,规律教程(有挂攻略);大神普及一...
指导大家!wepoker透视辅... 指导大家!wepoker透视辅助下载,wepoker游戏的安装教程,规律教程(有挂技巧);最新版20...
技术分享!pokemmo手机辅... 技术分享!pokemmo手机辅助软件,hhpoker有没有外挂,2025新版(有挂软件)准备好在po...
总算明白!hhpoker真的假... 总算明白!hhpoker真的假的,wepokerplus外挂,新2025版(有挂技巧);《WPK辅助...
热点讨论!hhpoker万能辅... 热点讨论!hhpoker万能辅助器,wejoker黑侠辅助器,2025新版技巧(有挂神器);大神普及...