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

相关内容

热门资讯

透视烘培!拱趴大菠萝有什么挂(... 透视烘培!拱趴大菠萝有什么挂(透视)pokemmo脚本辅助下载(辅助)本来是真的有app(哔哩哔哩)...
透视手段!pokemmo辅助器... 透视手段!pokemmo辅助器脚本下载(透视)werplan透视挂(辅助)其实是有技巧(哔哩哔哩)1...
透视手段!哈糖大菠萝可以开挂吗... 透视手段!哈糖大菠萝可以开挂吗(透视)pokemmo脚本辅助(辅助)原来有教程(哔哩哔哩)1、每一步...
透视妙招!pokerworld... 透视妙招!pokerworld辅助器(透视)约局吧开挂(辅助)一直一直总是有神器(哔哩哔哩)1、游戏...
透视手筋!哈糖大菠萝辅助器(透... 透视手筋!哈糖大菠萝辅助器(透视)德州透视脚本(辅助)真是是真的有插件(哔哩哔哩)1、超多福利:超高...
透视妙计!pokemmo脚本手... 透视妙计!pokemmo脚本手机版(透视)impoker辅助(辅助)一直一直都是有工具(哔哩哔哩)运...
透视手筋!哈糖大菠萝破解器(透... 透视手筋!哈糖大菠萝破解器(透视)拱趴大菠萝万能挂(辅助)切实真的是有方法(哔哩哔哩)拱趴大菠萝万能...
透视办法!xpoker怎么作必... 透视办法!xpoker怎么作必弊(透视)德州局脚本(辅助)原来一直总是有技巧(哔哩哔哩)xpoker...
透视技法!werplan有挂吗... 透视技法!werplan有挂吗(透视)epoker透视(辅助)一直存在有教程(哔哩哔哩)1、任何we...
透视法门!大菠萝免费辅助(透视... 透视法门!大菠萝免费辅助(透视)哈糖大菠萝有挂吗5个常用方法(辅助)本来真的是有教程(哔哩哔哩)1....