Created
August 15, 2014 17:07
-
-
Save gerasimua/99edc3ae3324ebd4a29c to your computer and use it in GitHub Desktop.
PreAjax for check session expiration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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