[CLOSED] Is it possible to ensure ajax calls are executed sequentially in Ext.Net 2.x/Ext Js 4.x?

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Is it possible to ensure ajax calls are executed sequentially in Ext.Net 2.x/Ext Js 4.x?

    I basically want to queue them (FIFO) and execute them one at the time. The calls would not be blocked, I would rather ensure that they execute sequentially.

    There was another question posted here: http://forums.ext.net/showthread.php...ial-ajax-calls for Ext.Net 1.x.

    Thanks
    Last edited by Daniil; Mar 19, 2013 at 4:29 AM. Reason: [CLOSED]
  2. #2
    Hello!

    By default, AJAX requests are asynchronous so you cannot call them at one moment in some order and expect them to finish their work in the same order. However, you can do this using setting callbacks in request success property but each of them have to wait previous request.

    Also, you can call chain of methods on server side.
    Last edited by Baidaly; Mar 13, 2013 at 2:06 AM.
  3. #3
    The problem that I am trying to solve is related to a Master/Detail pattern where I have a master grid panel and a details grid panel (it is more complex, but for now this will do). The details grid panel is refreshed when the selection changes in the master grid panel.

    If the user is impatient and starts clicking like crazy on the master grid and changes the selection multiple times, it spawns multiple server requests. Even if the browser limits the number of concurrent ajax calls, things can get messed up and the results from the server may come back in a different order than that by which they were requested. It is possible to end up displaying the wrong detail information for the selected master.

    One way to prevent his scenario is to make sure the ajax calls that populate the stores execute in sequence. This way you'll always get the proper details.

    Another way is to mask the panel but I don't like this too much.

    I ended up preventing the selection change in the master grid panel when the details store is loading. It is not fool proof but that would do for now. The user can still paginate through the master data and trigger a selection change while the details are being refreshed.

    To get a consistent behavior at the application level is hard, and this is why I like to have a queue because then you can do all sorts of things, without having to worry about masking panels or implementing this or that event handler. You could cancel pending requests or you can refuse the execution of certain actions if the queue is not empty.
  4. #4
    If using [DirectMethod] you can set the Async=false property on the Attribute.
    Geoffrey McGill
    Founder
  5. #5
    if your details load is fast enough, it shouldn't be an issue right? also, you can try adding a buffer to the listener so they don't fire as rapidly.
  6. #6
    @jchau: that is correct. The app is already in production and it is very fast, and it's not an issue. This is why I didn't worry about it.

    However, we might deploy the app in an environment where the speed is not that great, and these issues might start to surface.
  7. #7
    Hello,

    An interesting fact that Session makes AJAX requests synchronous by default.
    http://forums.ext.net/showthread.php...ll=1#post72625
    http://forums.ext.net/showthread.php...ll=1#post72773
  8. #8
    Thank you for the answers. I think you can close this thread. I created a request on the Ext Js forum to have this feature added.

    In the meantime, I think I will give this a try: http://www.sencha.com/forum/showthread.php?243017

    I will also use the buffer setting as jchau suggested.
  9. #9
    @jchau: Just curious, what buffer value did you use? I played with 500 and it seems to be fine.
  10. #10
    @jchau: I came across an interesting side effect of setting the buffer for the gridpanel selection change. I have a few grid panels where I double-click on a row and I navigate to a form. Because the buffer value was set to 500 the double-click changed the selection but it didn't fire the select event which sets a variable I need to retrieve the data for that form. !@#$. I'm switching back to the default. I have to think more about this.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: Mar 10, 2012, 2:43 AM
  2. Single mask for all ajax calls
    By huzzy143 in forum 1.x Help
    Replies: 3
    Last Post: Jan 24, 2012, 6:37 PM
  3. Sequential ajax calls
    By costab in forum 1.x Help
    Replies: 1
    Last Post: May 21, 2011, 11:51 AM
  4. [CLOSED] Handling Un-Authenticated Ajax calls [401 Error]
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 22, 2011, 9:49 AM
  5. Replies: 15
    Last Post: Feb 03, 2011, 1:27 PM

Posting Permissions