Tus*_*are 3 html javascript asp.net asp.net-mvc jquery
在页面加载时,我正在启动一个计时器来检查会话是否已过期.我通过对页面进行ajax调用来检查到期日期.我需要在到期前5分钟显示警报,并在到期后重定向到默认页面.这是我的代码:
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";
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
警报在5分钟后显示,但如果用户未单击"确定",则会阻止javascript并且不再进行ajax调用.
有没有办法我可以显示警报而不阻止它?我不想使用jQuery对话框.
| 归档时间: |
|
| 查看次数: |
3060 次 |
| 最近记录: |