Ajax Session Timeout 超时 处理

  • 来源:本站
  • 发布时间:2019-08-13
  • 172已阅读
您现在的位置:首页 >> 西方诗歌 >> 文章
简介 /***Author:LarryLi*Date:2013-12-5*Email:*/varSession=function(){vardefaults={title:SessionNotifi

	Ajax Session Timeout 超时 处理

/***Author:LarryLi*Date:2013-12-5*Email:*/varSession=function(){vardefaults={title:SessionNotification,message:Yoursessionisabouttoexpire.,keepAliveUrl:/admin/session/keep-alive,redirUrl:/account/timed-out,logoutUrl:/account/logout,warnAfter:900000,//15minutesredirAfter:1200000//20minutes};varo=defaults,dialogTimer,redirTimer;varcontrolRedirTimer=function(action){switch(action){casestart://Dialoghasbeenshown,ifnoactiontakenduringredirperiod,redirectredirTimer=setTimeout(function(){=;},);break;casestop:clearTimeout(redirTimer);break;caserestart:clearTimeout(redirTimer);redirTimer=setTimeout(function(){=;},);break;}};varcontrolDialogTimer=function(action){switch(action){casestart:dialogTimer=setTimeout(function(){$(#sessionTimeout-dialog).modal(show);controlRedirTimer(start);},);break;casestop:clearTimeout(dialogTimer);break;caserestart:clearTimeout(dialogTimer);dialogTimer=setTimeout(function(){$(#sessionTimeout-dialog).modal(show);controlRedirTimer(restart);},);break;}};vardoKeepAlive=function(){$.ajax({type:POST,url:,success:function(){//StopredirecttimerandrestartwarningtimercontrolRedirTimer(restart);controlDialogTimer(restart);}});};return{sessionTimeout:function(options){if(options){o=$.extend(defaults,options);}varwarning_dialog=divclass="modalfade"id="sessionTimeout-dialog"+divclass="modal-dialogmodal-small"+divclass="modal-content"+divclass="modal-header"+buttonid="_close"type="button"class="close"data-dismiss="modal"aria-hidden="true"times;/button+h4class="modal-title"++/h4+/div+divclass="modal-body"++/div+divclass="modal-footer"+buttonid="sessionTimeout-dialog-logout"type="button"class="btnbtn-default"Logout/button+buttonid="sessionTimeout-dialog-keepalive"type="button"class="btnbtn-primary"data-dismiss="modal"StayConnected/button+/div+/div+/div+/div$(body).append(warning_dialog);$(#sessionTimeout-dialog-logout).on(click,function(){=;});$(#_close,#sessionTimeout-dialog-keepalive).click(function(){doKeepAlive();});//BeginwarningperiodcontrolDialogTimer(start);},sessionTimeoutKeepAlive:function(){controlRedirTimer(restart);controlDialogTimer(restart);}};}();$(function(){({title:SessionTimeoutNotification,message:Yoursessionisabouttoexpire.,keepAliveUrl:contextPath+/admin/session/keep-alive,redirUrl:contextPath+/account/login,logoutUrl:contextPath+/account/logout,warnAfter:1500000,redirAfter:1780000});$(document).ajaxComplete(function(){();});});。