JSDO properties, methods, and events reference : afterLogout event
  

afterLogout event

Fires when the logout( ) method on the current Session object completes execution after it was called asynchronously.
Applies to:progress.data.Session class
The following parameters appear in the signature of any event handler (callback) function (or functions) that you subscribe to this event:

Syntax

function ( login-session , error-object )
login-session
A reference to the Session object that fired the event.
error-object
A reference to any Error object that might have been thrown as login-session processed the logout( ) method response. This value can be null. For more detailed information about any response (successful or unsuccessful) returned from the web server, you can also check the XMLHttpRequest object (XHR) returned by its lastSessionXHR property.
Note: These callback parameters provide the same information that is available after a synchronous invocation of logout( ). Also, the logout( ) method does not send a request to the web application if it is using Anonymous authentication. In this case, logout( ) invoked asynchronously will nevertheless invoke any afterLogout event callback that has been subscribed when it is done executing.
Application code can subscribe a callback to this event by invoking the subscribe( ) method on a Session object.

Example

The following code fragment subscribes the function, onAfterLogout, to handle the afterLogout event fired on the session, empSession, after the logout( ) method is called asynchronously. If an Error object is passed in, the event callback displays a message:
empSession.subscribe('afterLogout', onAfterLogout);

empSession.logout( { async : true } );


/* Invoked by empSession when it finishes executing the logout operation */
function onAfterLogout( pdsession, errorObject ) {
var msg;

msg = errorObject ? '\n' + errorObject.message : '';
if ( pdsession.lastSessionXHR === null ) {
alert("logout succeeded");
return;
}
alert("There was an error attempting log out." + msg);
}

See also:

lastSessionXHR property, logout( ) method (Session class), subscribe( ) method (Session class)