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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 > > > [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<prototype-scriptaculous%[email protected]> > <prototype-scriptaculous%[email protected]<prototype-scriptaculous%[email protected]> > > > > > . > > > 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 > [email protected]. > To unsubscribe from this group, send email to > [email protected]<prototype-scriptaculous%[email protected]> > . > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
