Async call after Session Timeout

Hi!
We are using lots of async control (Ajax) from WMPortal 7 . We would like to know how to handle Ajax error (espacially session time out).
ie: we would like to send the user to the login page if he click to a async control button after the session timeout occur!
Thanks

FYI: we’ve made some improvements in this area for the upcoming release, but in the meantime, you can always increase the session length to minimize the number of times this occurs.

Regards,
–mark

To remove the default CAF async error handlers on a page, invoke the following javascript:

CAF.Dialag.WarnAppender.stop();
CAF.Dialog.ErrorAppender.stop();

To add your own handler, invoke the following javascript:

Logger.addAppender(function(message, level, category) {
// custom handling logic here, for example:
// CAF.Dialog.warn(message)
}, Logger.WARN);

Following is an example handler that will refresh the page with a login screen if the user’s session has timed out, and do nothing (not display any error message) otherwise:

Logger.addAppender(function(message, level, category) {
if (message.match(/<form[^>]name\s=\s*[“‘][^’”]*login/i)) {
document.location.href = document.location.href + (document.location.href.indexOf(‘?’) == -1 ? ‘?’ : ‘&’); + “t=” + new Date().getTime();
}
}, Logger.WARN);

Note that as Mark said, MWS 7.1 will detect if the user’s session has timed out, and display a session timeout message and link to login page instead of a generic error message.</form[^>

Hmm, try finding the above message in this page’s html source to see the correctly formatted source code.

I am trying to redirect the user on login page instead of showing the error message. Following is the code that i use

Logger.addAppender(
function(message, level, category) {

Mark,

Is this issue resolved in 7.1 version?

Khurram

Nothing has changed in this regard for mws 7.1.x. The regular expression

/<form[^>]name\s=\s*[“‘][^’”]*login/i

(you have to view the html source of the page to see the actual expression) matches a form element with a name attribute containing “login”. The above code assumes that if the async response contains a form like this instead of the content it expected, the user’s session has timed out. If you have a custom login form, your custom login form might not match this expression.</form[^>