Skip to content

Instantly share code, notes, and snippets.

@gerasimua
Created August 15, 2014 17:07
Show Gist options
  • Save gerasimua/99edc3ae3324ebd4a29c to your computer and use it in GitHub Desktop.
Save gerasimua/99edc3ae3324ebd4a29c to your computer and use it in GitHub Desktop.
PreAjax for check session expiration
$(function(){
$.ajaxPrefilter(function(options, _, jqXHR) {
jqXHR.success(function(data) {
try{
//return data with json in string if expired session
var jsonData = JSON.parse(data);
if(jsonData.message && (jsonData.message == 'autherror')){
//jqXHR.abort() - didn't work
document.body.innerHTML = '';
window.location = '/site_login';
}
} catch (error){}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment