0
你能告訴我爲什麼這不起作用。也試圖與window.unload,但它也沒有工作發送數據到php窗口關閉
window.onbeforeunload = function(){
$.ajax({
url:'logout.php',
type:'POST',
data:{user:$("#user").val()},
success: function(response){
alert(response);
}
})
}
Duplicate http://stackoverflow.com/questions/8743119/preventing-web-browser-from-closing-until-ajax-response-is-returned – bhb
改正它是重複的問題,但對於答案你應該使用'async: FALSE' –