$(window).bind('beforeunload', function () {
return "Are you sure you want to exit? Please complete sign up or the app will get deleted.";
});
$(window).unbind("beforeunload");
<?php
class Articless {
public function articles_all(){
//Zapros
$query = "SELECT * FROM articles ORDER BY id DESC";
$result = mysqli_query($link, $query);
if (!$result)
die(mysqli_error($link));
//Izvlekaem iz bd
$n = mysqli_num_rows($result);
$articles = array();
for ($i = 0; $i < $n; $i++){
$row = mysqli_fetch_assoc($result);
$articles[] = $row;
}
return $articles;
}
}
$sql = mysql_query("INSERT INTO temp (login, id, date, status) VALUES ('$login', '$id', '$komm', '$time', '0') ");
$data = array(
'status' => 'success',
'redirect' => '/page',
'message' => 'Действие успешно! Ожидайте!'
);
print(json_encode($data));
function nameMethod() {
$.ajax({
url: '/url',
dataType: "json",
type: 'POST',
success: function (response) {
window.setTimeout(function () {
alert(response.message)
}, 2000);
window.location.href = response.redirect;
}
});
}
<button type="button" onclick="nameMethod()">Submit</button>