On 24 September 2010 20:21, 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.
> For more options, visit this group at 
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>

Don't do 2 requests.

Make 1 request and get both sets of data from the server at the same time.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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

Reply via email to