1 function window.onbeforeunload() {
 2 
 3     var jhid = $("#ctl00_ContentBody_hfGuid").val();
 4     $.ajax({
 5         url: "AjaxServices/AjaxService.asmx/DeleteDeviceAndWorkContent", // ajax 调用后台方法
 6         type: "POST",
 7         async: false,
 8         data: "{'jhid':'" + jhid + "'}", // 参数
 9         dataType: "json", // 返回类型
10         contentType: "application/json; charset=utf-8",
11         //成功时调用的方法
12         success: function(data) {
13         },
14         error: function(XMLHttpRequest, textStatus, errorThrown) {
15             alert(XMLHttpRequest);
16             alert(textStatus);
17             alert(errorThrown);
18         }
19     });
20     
21 }


解决方法:

使用ajax,设置为同步,不要使用异步(上面代码红色显示!)

相关文章:

  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2021-11-22
  • 2021-11-23
  • 2022-02-18
  • 2021-08-14
猜你喜欢
  • 2021-12-28
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案