Results 1 to 4 of 4

Thread: Abort Ext.Ajax request AND abort success or failure callback

  1. #1
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    44

    Default Abort Ext.Ajax request AND abort success or failure callback

    Hi,

    I'm searching a way that will let me abort any Ext.Ajax success or failure callback from the same function.

    Let me explain: I have multiples Ajax request anywhere on my application, now the project move into a multiuser one, so I have to do a user management system, I have to force user to log into the system.

    I've done something like this:

    PHP Code:
    Ext.Ajax.on('requestcomplete', function(response)
        {
            var 
    logged_in CheckLoginStatus(response);
        }
    ); 
    It works like this:
    1. user is making a regular action in my application
    2. the PHP backend intercept the request before actually making it, finds that the user's not logged in anymore
    3. operation in the backend is aborted
    4. PHP returns an error that user needs to login
    5. my function above intercepts that error and fires a new Ext window that tell user it must login again.

    All is working great till here.
    Now, after the login panel has been shown, the request's callbacks (success or failure) are still fired, and I don't want that.

    And I just do not want to have to test every ajax callback, I want to find a way to fire some functions right after "CheckLoginStatus" that will abort any callback after that.

    Any thoughts about this ?

    Thanks

    Stephane

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    It's a bit tricky, but the following works:
    Code:
    Ext.Ajax.on('requestcomplete', function(response, options){
      var logged_in = CheckLoginStatus(response);
      if (!logged_in) {
        delete options.success;
        delete options.failure;
        delete options.callback;
        // other stuff
      }
    });

  3. #3
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    44

    Default

    Thanks a lot !

    That did do the trick and saved me a LOT of code !

  4. #4
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    23

    Default

    I know this is from a very long time ago, but thank you very much. This little trick is still extremely effective and saved me literally hundreds of lines of code spread across dozens of various view controllers. Thanks!

Similar Threads

  1. after Ext.Ajax.abort
    By aj3423 in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 7 Feb 2009, 8:00 AM
  2. Ext.Ajax.request - failure/success?
    By dante in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 17 Nov 2007, 9:56 AM
  3. [2.0b1] failure with getForm().load success with Ext.Ajax.request
    By sdalu in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 18 Oct 2007, 7:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •