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

相关内容

热门资讯

透视总结"wepok... 透视总结"wepoker免费脚本咨询"详细辅助wepoke教程(辅助真的假的技巧)准备好在wepok...
透视app"poke... 透视app"pokernow辅助工具"详细辅助揭秘教程(辅助器技巧)关于pokernow辅助工具机制...
透视黑科技"hhpo... 透视黑科技"hhpoker辅助器"详细辅助系统教程(辅助器免费教程);hhpoker辅助器软件透明挂...
透视线上"hhpok... 透视线上"hhpoker透视方法"详细辅助揭秘攻略(俱乐部辅助透视)是一款可以让一直输的玩家,快速成...
透视存在"werpl... 透视存在"werplan辅助软件"详细辅助玩家教你(私人局外卦攻略),支持语音通讯、好友开房及战队组...
透视系统"wepok... 透视系统"wepoker破解游戏盒子"详细辅助必备教程(作弊辅助攻略);wepoker破解游戏盒子软...
透视软件"wepok... 透视软件"wepoker永久免费脚本"详细辅助存在挂教程(俱乐部辅助攻略)1、不需要AI权限,帮助你...
透视ai"wpk插件... 透视ai"wpk插件"详细辅助规律教程(有透视软件)是由北京得wpk插件黑科技有限公司精心研发的一款...
透视代打"德普之星私... 1、透视代打"德普之星私人局辅助器"详细辅助教你攻略(私人局可以透视技巧);详细教程。2、德普之星私...
透视辅助"aapok... 透视辅助"aapoker怎么开辅助器"详细辅助可靠技巧(科技辅助器技巧)1、很好的工具软件,可以解锁...