function send(){
$.ajax({
url: "url",
async: true // 这里要用异步
})
}
window.onbeforeunload(){
send()
return true;
}
注意:Ajax中一定要用异步 否则下面的异常
"NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load '': Synchronous XHR in page dismissal. See https://www.chromestatus.com/feature/4664843055398912 for more details."