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 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 get jquery to append output immediately after each ajax call in a loop

From Dev

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

From Dev

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

From Dev

Ajax call inside each loop

From Dev

jQuery loop without each and callback function

From Dev

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

From Dev

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

From Dev

How to prevent page reloading after ajax call jquery

From Dev

Jquery Ajax call not executed in for loop

From Dev

Storing Each Iteration of Array after Loop Completion

From Dev

Jquery Deferred in each loop with ajax callback

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?

From Dev

Ajax call inside each loop

From Dev

jQuery loop without each and callback function

From Dev

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

From Dev

Make loop for ajax call in jquery

From Dev

JQUERY - Bubbling after ajax call

From Dev

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

From Dev

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

From Dev

Jquery Ajax call in a loop

From Dev

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

From Dev

Jquery Ajax call not executed in for loop

From Dev

Loop in Jquery after Ajax call

From Dev

Ajax request inside loop, page reload after completion

From Dev

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

From Dev

How To Call A Callback Function After For Await Loop Ends

Related Related

  1. 1

    How to manage a redirect request after a jQuery Ajax call

  2. 2

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

  3. 3

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

  4. 4

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

  5. 5

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

  6. 6

    Ajax call inside each loop

  7. 7

    jQuery loop without each and callback function

  8. 8

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

  9. 9

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

  10. 10

    How to prevent page reloading after ajax call jquery

  11. 11

    Jquery Ajax call not executed in for loop

  12. 12

    Storing Each Iteration of Array after Loop Completion

  13. 13

    Jquery Deferred in each loop with ajax callback

  14. 14

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

  15. 15

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

  16. 16

    Ajax call inside each loop

  17. 17

    jQuery loop without each and callback function

  18. 18

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

  19. 19

    Make loop for ajax call in jquery

  20. 20

    JQUERY - Bubbling after ajax call

  21. 21

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

  22. 22

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

  23. 23

    Jquery Ajax call in a loop

  24. 24

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

  25. 25

    Jquery Ajax call not executed in for loop

  26. 26

    Loop in Jquery after Ajax call

  27. 27

    Ajax request inside loop, page reload after completion

  28. 28

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

  29. 29

    How To Call A Callback Function After For Await Loop Ends

HotTag

Archive