asp.net call WebMethod from Javascript asyncronous

≡放荡痞女 提交于 2019-11-28 00:26:49

you should call the page methods using an Async call instead.

have a look at the below. It is a generic way to call a page method using JQuery

$.ajax({
  type: "POST",
  url: "PageName.aspx/MethodName",
  data: "{}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
    // Do something interesting here.
  }
});

you should use this code to replace the page method calls

PageMethods.Restart(function (text))

PageMethods.Update(function (text))

It's because an Request only Proceeds when no other Request is processing. Thats because two Processes can't acess to the same SessionState (Sessionstate is not Threadsafe).

So to achieve that Requests are processed at the same time, you have to set EnableSessionState in the @Page directive to either 'ReadOnly' or 'false'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!