I’m writing a jQuery Mobile application that requires user authentication. The same user cannot have her session open from multiple locations: if user logins from another browser, the previous session is marked as dead.
If the user attempts to move to another page with the browser with the dead session, “Error loading page” message is displayed. This is bad because user might not know why she’s getting this error. Is it possible to tap in to the error event so I could check for the status of the session and redirect user to the login page if the session is dead?
I ended up forking jQuery Mobile and adding an ability to add custom error handler: https://github.com/jquery/jquery-mobile/pull/2504 I think this superior to the other suggestions because it doesn’t add any overhead except when the error actually occurs.
UPDATE: There will be a new pageloadfailed event in jQuery Mobile RC1. That will solve this problem elegantly and according to project standards.