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.com<prototype-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.