On page load, I am starting a timer to check if session is expired. I am checking expiry by making ajax call to a page. I need to display alert 5 minutes before expiry and redirect to default page after expiry. Here is my code:
function startSessionCheckTimer() {
setInterval(checkSessionExpiry, 60000);
}
function checkSessionExpiry() {
$.ajax({
type: "POST",
url: "/Default.aspx/IsSessionOpen",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (time) {
if (time.d == 5) {
//alert("Your session will expire in 5 minutes.");
setTimeout(function () { alert('Your session will expire in 5 minutes.'); }, 100);
}
else if (time.d <= 0) {
window.location = "/Default.aspx";
}
}
});
}
Alert is displayed after 5 minutes, but if user does not click OK, it blocks the javascript and no further ajax calls are made.
Is there a way that I can display Alert without blocking it? I do not want to using jQuery dialog.
No, there is no way to display a native alert without halting the execution of the script.
The only way is to use a dialog or something that is not a native alert
http://jqueryui.com/dialog/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With