[Proto-Scripty] Re: AJAX callbacks are not executed atomically?
I don't need A to finish before B. I need A's callbacks to not be cut off by B's instantiation. On Sep 24, 12:44 pm, Phil Petree phil.pet...@gmail.com wrote: If you want a() to finish before b() and b() to finish before c() then you will have to daisy chain in the onComplete code. On Fri, Sep 24, 2010 at 3:21 PM, JoJo tokyot...@gmail.com wrote: I have several lines of code that I want to run atomically (no context switches to other code). Please look at the following barebones example that illustrates the issue: //= function doAjax() { console.info('making request'); new Ajax.Request( url, { onSuccess: function() { console.info('success'); }, onFailure: function() { console.info('failure'); }, onComplete: function() { console.info('complete'); } } ); } doAjax(); doAjax(); //= If the processor is faster than the network, I expect the output to be : making request making request success complete success complete However, under certain conditions, success+complete is sometimes not atomic. Here's some output that I have seen: (A) making request (A) success (B) making request (A) complete (B) success (B) complete This is against my expectations and breaks my code logic - the website fails to function when complete does not IMMEDIATELY follow success. Can someone shed some light on why this is happening? I thought AJAX is only asynchronous while waiting for the server and should become synchronous as it's executing the callback code... -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: AJAX callbacks are not executed atomically?
I believe I solved the problem. I had a queue of work orders. One of these work orders queued up another work order, so it was a nested AJAX request - BAD IDEA! On Sep 24, 12:56 pm, JoJo tokyot...@gmail.com wrote: I don't need A to finish before B. I need A's callbacks to not be cut off by B's instantiation. On Sep 24, 12:44 pm, Phil Petree phil.pet...@gmail.com wrote: If you want a() to finish before b() and b() to finish before c() then you will have to daisy chain in the onComplete code. On Fri, Sep 24, 2010 at 3:21 PM, JoJo tokyot...@gmail.com wrote: I have several lines of code that I want to run atomically (no context switches to other code). Please look at the following barebones example that illustrates the issue: //= function doAjax() { console.info('making request'); new Ajax.Request( url, { onSuccess: function() { console.info('success'); }, onFailure: function() { console.info('failure'); }, onComplete: function() { console.info('complete'); } } ); } doAjax(); doAjax(); //= If the processor is faster than the network, I expect the output to be : making request making request success complete success complete However, under certain conditions, success+complete is sometimes not atomic. Here's some output that I have seen: (A) making request (A) success (B) making request (A) complete (B) success (B) complete This is against my expectations and breaks my code logic - the website fails to function when complete does not IMMEDIATELY follow success. Can someone shed some light on why this is happening? I thought AJAX is only asynchronous while waiting for the server and should become synchronous as it's executing the callback code... -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: AJAX callbacks are not executed atomically?
Same difference. Since the AJAX calls are Async you have no control over what gets completed first or what gets interrupted by what. If script a does a complex query taking 2.2 seconds and returns a large data set while script b does a simple query that takes .02 seconds and returns 100 bytes, script b will almost certainly interrupt script a. You have two options (as far as I know), you can daisy chain the calls and thereby guarantee the call/completion order or you can create your own semaphore process and lock (sleep) the onComplete of script b until script a clears the i'm done flag. On Fri, Sep 24, 2010 at 3:56 PM, JoJo tokyot...@gmail.com wrote: I don't need A to finish before B. I need A's callbacks to not be cut off by B's instantiation. On Sep 24, 12:44 pm, Phil Petree phil.pet...@gmail.com wrote: If you want a() to finish before b() and b() to finish before c() then you will have to daisy chain in the onComplete code. On Fri, Sep 24, 2010 at 3:21 PM, JoJo tokyot...@gmail.com wrote: I have several lines of code that I want to run atomically (no context switches to other code). Please look at the following barebones example that illustrates the issue: //= function doAjax() { console.info('making request'); new Ajax.Request( url, { onSuccess: function() { console.info('success'); }, onFailure: function() { console.info('failure'); }, onComplete: function() { console.info('complete'); } } ); } doAjax(); doAjax(); //= If the processor is faster than the network, I expect the output to be : making request making request success complete success complete However, under certain conditions, success+complete is sometimes not atomic. Here's some output that I have seen: (A) making request (A) success (B) making request (A) complete (B) success (B) complete This is against my expectations and breaks my code logic - the website fails to function when complete does not IMMEDIATELY follow success. Can someone shed some light on why this is happening? I thought AJAX is only asynchronous while waiting for the server and should become synchronous as it's executing the callback code... -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com prototype-scriptaculous%2bunsubscr...@googlegroups.comprototype-scriptaculous%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.