jquery - How to manage multiple ajax request/responses with a for loop and an array -


i trying make ajax request using loop , array in jquery mobile.

i trying to:

  1. send requests.
  2. store responses.
  3. after ajax completed, perform action.

here's have far doesn't work (that's why i'm here).

var req1 = []; var req2 = []; var size = //some number passed here//;  //create size number of unique ajax json requests (i = 0; < size; i++) {         requesta[i] = // request json datatype //;         requestb[i] = $.ajax(requesta[i]);    };  (j = 0; j < size; j++) {     requestb[j].done (function (response) {            if (response[j].results.length > 0) (                   requestb[j] = response[j].results;                     } });     $(document).ajaxstop (function() {         // after ajax done //    }); 

try lock array when in callback.

something this

var isloked = false;  // ... if (response[j].results.length > 0 && !islocked) (         islocked = true;             requestb[j] = response[j].results;                     islocked = false; } 

p.s. why dont want make request , assign callback @ same loop?


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -