Hello,
I read a couple of articles here that inspired my solution but wondering if i'm doing it the right way.
What I did was to create an event that catches an jQuery ajax error:
$('body').ajaxError(function(xmlHttpRequest, ajaxOptions, error) {
if (!locked) CheckUserAuthentication();
});
Then the CheckUserAuthentication() goes through another ajax call to a webservice that attempts to check if authentication is still active. if it returns a value that it needs to re-login, I then prompt a modal box that displays a log-in form. If the ajax call fails, then it's safe to assume that internet connection has been lost, so I prompt another modal box that displays a message and a js loop that checks the connection again in intervals.
My first concern is that the event code above actually repeats triggering itself if it reaches to the second ajax error making it a repeating loop. So I made a variable that sets a boolean whether to lock the event to prevent this.
My questions:
1) Am I doing it correctly?
2) If yes, then can I dispose an ajax exception so that i don't need to lock the .ajaxError event from re-triggering?
3) Any other ideas much efficient that what I'm doing?
I appreciate all the help!