This is not sutable because inparallel maybe run othes async calls
which I dont need wait to complete

On 22 ноя, 18:04, "Brian Marquis" <br...@quotepro.com> wrote:
> Forgot to unregister the responder. See revised watcher:
>
> var watcher = {
>
>   start: function() {
>
>     Ajax.Responders.register(responder);
>
>   },
>
>     stop: function() {
>
>         Ajax.Responders.unregister(responder);
>
>     },
>
>     responder: {
>
>       onComplete: function() {
>
>         if ( Ajax.activeRequestCount == 0 ) {
>           finalize();
>
>         }
>
>       }
>
>   }
>
> };
>
> From: prototype-scriptaculous@googlegroups.com
> [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Brian Marquis
> Sent: Monday, November 22, 2010 9:43 AM
> To: prototype-scriptaculous@googlegroups.com
> Subject: RE: [Proto-Scripty] Do somthing only after two Ajax calls return
> results
>
> var watcher = {
>
>   watching: false,
>
>   start: function() {
>
>     watching = true;
>
>     Ajax.Responders.register({
>
>       onComplete: function() {
>
>         if ( watching && Ajax.activeRequestCount == 0 ) {
>           finalize();
>
>         }
>
>       }
>
>     });
>
>     stop: function() {
>
>          watching = false;
>
>     }
>
> };
>
> // start your requests, then
>
> watcher.start();
>
> function finalize() {
>
>   watcher.stop();
>
>  // do other stuff
>
> }
>
> From: prototype-scriptaculous@googlegroups.com
> [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Daff Niles
> Sent: Sunday, November 21, 2010 8:10 PM
> To: prototype-scriptaculous@googlegroups.com
> Subject: Re: [Proto-Scripty] Do somthing only after two Ajax calls return
> results
>
> Hi Buda,
>
> Having had this issue, and seen other frameworks sorting this out, the
> quickest and easiest way I have found is to have to global variables (flags)
> in the page, one for each of the Ajax calls.  
>
> The Ajax callback method for each then sets the flag for that call back,
> then checks if both flags have been set, and if so, calls the function of
> your choice that will then continue the processing you desire.
>
> Because each callback only sets its own flag, but then checks both, it will
> not matter which order they callbacks are received and processed.
>
> pseudo code (untested)
>
> var flag_1 = false;
>
> var flag_2 = false;
>
> function callback_function_1() {
>
>             // Processing...
>
>             flag_1 = true;
>
>             if(flag_1 && flag_2) {
>
>                         // Call final method...
>
>                         finalize()
>
>             }
>
> }
>
> function callback_function_2() {
>
>             // Processing...
>
>             flag_2 = true;
>
>             if(flag_1 && flag_2) {
>
>                         // Call final method...
>
>                         finalize()
>
>             }
>
> }
>
> function finalize () {
>
>             // Complete processing here...
>
>             // If we need to call again, then reset the two flags in here...
>
> }
>
> Hope that helps.
>
> Regards.
>
> daff
>
> SOFTWARE ENGINEER
>
> andrew 'daff' niles | spidertracks | 117a the square
>
> po box 5203 | palmerston north 4441 | new zealand
>
> P: +64 6 353 3395 | M: +64 21 51 55 48
>
> E: d...@spidertracks.co.nz  www.spidertracks.com
> <http://www.spidertracks.com/>
>
> On 22/11/2010, at 9:40 AM, buda wrote:
>
> I have two calls run asyncronously
> I need to wait when they both is comleted and only then do somthing
> Two - is an example - they may be N-calls :)
>
> What is the right method to do it?
> Is theere an object somthing AsyncWaitFor(AjaxCall1...AjaxCallN)?
>
> --
> 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 
> athttp://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 
> athttp://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 
> athttp://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.

Reply via email to