1. #1
    Sencha User
    Join Date
    Mar 2007
    Posts
    580
    Vote Rating
    0
    dolittle is an unknown quantity at this point

      0  

    Default delay closing of a browser window

    Hi,

    I have an event listener:
    Code:
    Ext.EventManager.on(window, 'beforeunload', terminateSession);
    In the function teminateSession I`m sending an ajax request to the server to tell him that the session should be closed. I need to:
    - delay the closing of the window until I get a response from the server.
    - or for a few seconds so I`ll know the server probably got my ajax request.

    Is it possible?

    Thanks

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    580
    Vote Rating
    0
    dolittle is an unknown quantity at this point

      0  

    Default

    BUMP

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,569
    Vote Rating
    55
    Animal will become famous soon enough Animal will become famous soon enough

      0  

    Default

    This will probably just be fire and forget, but it should get enough time to send a small "logout" request.

    We do this in our legacy app which maintains a stateful session from the webserver back to the legacy backend code which maintains a unix process. We try to clear it up as soon as the use navigates away of closes the window.

  4. #4
    Sencha - Services Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,965
    Vote Rating
    12
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Cool Sounds like a job for a Synchronous Call..

    With this in place, the window would not close/back/forward until you get a response:

    Code:
    var terminateSession = function(){
    
     var response = Ext.lib.Ajax.request('PUT','logout.php', null,null,{async:false});
     
     
     //if you wanted to prevent the action just:
     // return false;
     
    }
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,569
    Vote Rating
    55
    Animal will become famous soon enough Animal will become famous soon enough

      0  

    Default

    It's not an event you can cancel.

Thread Participants: 2