I would like doing in javascript (jQuery):
if (close tab || close window) {
$.ajax({
type: "POST",
url: "process_form.php",
data: dataString
});
}
Is this possible without message if you want leave page etc?
There is only one useful event you can rely on for that reason, onbeforeunload
.
window.onbeforeunload = function() {
$.ajax({});
};
Unless you explicitly return false
from that event, there is no message to the user. You might want to create a synchronised request anyway, because the browser will not wait for an asyncronous request to finish.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.