jjzjj

requestsPending

全部标签

Javascript:等到ajax请求完成关闭页面

这个问题在这里已经有了答案:JavaScript,browsers,windowclose-sendanAJAXrequestorrunascriptonwindowclosing(9个回答)关闭5年前。我希望浏览器在发送ajax请求之前保持页面打开。这是我想象中的样子varrequestsPending=0;window.onbeforeunload=function(){showPleaseWaitMessage();while(requestsPending>0);}//calledbeforemakingajaxrequest,atomicsomehowfunctionajax