JQuery: How to callback each loop after completion of ajax call?

user2224250

How to callback each loop after completion of ajax call.

Please find my code as follows.

Story:

Let us assume I have 3 values X,Y,Z. Firstly, I am taking X value, sending to django views and their using requests module for getting some info and pushing to the div class push_new_info_here, in the next Iteration I have to take Y value. How to do ? please note: Previous ajax call should be succeeded .

Final word: I am collecting all the info of (X,Y,Z), then merging using python and pushing to the div class push_new_info_here

window.onload = function() {

  $.each(["X","Y","Z"], function( index, value ) {

      $.post('/find/'+value+'/',{},function(data){
          $('.push_new_info_here').empty();
          $('.push_new_info_here').html(data);
      });

  });

};
mplungjan

Like this - use .append if you want to see the data or change the timeout to something long enough for the user to see:

var arr = ["X","Y","Z"],cnt=0;

function postIt() {
  if (cnt >= arr.length) return; // stop
  $.post('/find/'+arr[cnt]+'/',{},function(data){
      $('.push_new_info_here').empty().html(data); // or .append
      cnt++; 
      postIt(); // or setTimeout(postIt,3000); // give server a breather
  });
}


$(function() {
  postIt();
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JQuery: How to callback each loop after completion of ajax call?

From Dev

How to get jquery to append output immediately after each ajax call in a loop

From Dev

Jquery Deferred in each loop with ajax callback

From Dev

Loop in Jquery after Ajax call

From Dev

Need to use the model attribute after completion of ajax call in jquery dialog

From Dev

AngularJS: How to execute a controller function AFTER completion of AJAX call in a service?

From Dev

How to call function after completion of async functions inside loop?

From Dev

How to call function after completion of async functions inside loop?

From Dev

How to wait for completion of an animation chain and an ajax call with jQuery?

From Dev

How can I call the callback function after each string iteration?

From Dev

Storing Each Iteration of Array after Loop Completion

From Dev

How To Call A Callback Function After For Await Loop Ends

From Dev

Jquery Ajax call in a loop

From Dev

Jquery run code after ajax in .each() loop finishes

From Dev

Jquery. Calling a function after .each loop with ajax calls

From Dev

Ajax call inside each loop

From Dev

Ajax call inside each loop

From Dev

jQuery loop without each and callback function

From Dev

jQuery loop without each and callback function

From Dev

Jquery Ajax call not executed in for loop

From Dev

Make loop for ajax call in jquery

From Dev

Jquery Ajax call not executed in for loop

From Dev

JQUERY - Bubbling after ajax call

From Dev

Ajax request inside loop, page reload after completion

From Java

How to manage a redirect request after a jQuery Ajax call

From Dev

How to generate content on ejs with jquery after ajax call to express server

From Dev

How to prevent page reloading after ajax call jquery

From Dev

How to call Ajax after OnChange or OnSelect event in jQuery DateRangePicker?

From Dev

in jquery how to call a function after an ajax request has been sent?

Related Related

  1. 1

    JQuery: How to callback each loop after completion of ajax call?

  2. 2

    How to get jquery to append output immediately after each ajax call in a loop

  3. 3

    Jquery Deferred in each loop with ajax callback

  4. 4

    Loop in Jquery after Ajax call

  5. 5

    Need to use the model attribute after completion of ajax call in jquery dialog

  6. 6

    AngularJS: How to execute a controller function AFTER completion of AJAX call in a service?

  7. 7

    How to call function after completion of async functions inside loop?

  8. 8

    How to call function after completion of async functions inside loop?

  9. 9

    How to wait for completion of an animation chain and an ajax call with jQuery?

  10. 10

    How can I call the callback function after each string iteration?

  11. 11

    Storing Each Iteration of Array after Loop Completion

  12. 12

    How To Call A Callback Function After For Await Loop Ends

  13. 13

    Jquery Ajax call in a loop

  14. 14

    Jquery run code after ajax in .each() loop finishes

  15. 15

    Jquery. Calling a function after .each loop with ajax calls

  16. 16

    Ajax call inside each loop

  17. 17

    Ajax call inside each loop

  18. 18

    jQuery loop without each and callback function

  19. 19

    jQuery loop without each and callback function

  20. 20

    Jquery Ajax call not executed in for loop

  21. 21

    Make loop for ajax call in jquery

  22. 22

    Jquery Ajax call not executed in for loop

  23. 23

    JQUERY - Bubbling after ajax call

  24. 24

    Ajax request inside loop, page reload after completion

  25. 25

    How to manage a redirect request after a jQuery Ajax call

  26. 26

    How to generate content on ejs with jquery after ajax call to express server

  27. 27

    How to prevent page reloading after ajax call jquery

  28. 28

    How to call Ajax after OnChange or OnSelect event in jQuery DateRangePicker?

  29. 29

    in jquery how to call a function after an ajax request has been sent?

HotTag

Archive