views:

141

answers:

2

Hi, I need to launch serveral ajax requests. For some reasons, I want do this synchroneous. That is to say that before launching an ajax request I have to know if the prior request has been finished.

The 'asynchronous : false" property of prototype's Updater object seems not work.

   // A loop to launch one after each other the requests uploading elements of chunk[] 
    for (i = 0; i < chunks.length; i++) {
    new Ajax.Updater( 'myId',
        AJAX_SERVER + 'serviceName=' + sServiceName + sServiceParams,
        { 
          evalScripts: true,
          method: 'get',
          asynchronous : false;
         } );
}
+4  A: 

As per the Prototype docs, asynchronous option -

Determines whether XMLHttpRequest is used asynchronously or not. Since synchronous usage is rather unsettling, and usually bad taste, you should avoid changing this. Seriously.

You can fire an asynchronous ajax request to the server, it will call a callback function set for the onSuccess/onComplete/onFailure handler. In that callback, you can call the next method, and so on.

Kirtan
A: 

Have it called by the first AJAX request's onComplete or onSuccess callbacks.

ceejayoz
No. The calls take place in a loop.
Pilooz