jQuery ajax complete and release a php file? -


i have 150 checkboxes on site , every checkbox class .generujbox call ajax script:

$(".generujbox").click(function(){     $(".progress-indicator").show();     var idcheck = $(this).val();      if($(this).is(":checked")) {          $.ajax({                  type: "post",                  url: "boxsave.php",                  data: { genbox: idcheck, liczba: "1" },                 success: function(msg){                  $(".generujbox").ajaxcomplete(function(event, request, settings){                  if(msg == \'ok\')                 {                     $(".progress-indicator").hide();                 }                  else                  {                      $(".progress-indicator").show();                 }});}});      } else {       $.ajax({                  type: "post",                  url: "boxsave.php",                  data: { genbox: idcheck, liczba: "0" },                 success: function(msg){                  $(".generujbox").ajaxcomplete(function(event, request, settings){                  if(msg == \'ok\')                 {                     $(".progress-indicator").hide();                 }                  else                  {                      $(".progress-indicator").show();                 }});}});      }     }); 

and looks ok. after click on checkbox progress-indicator working 1second , after hide (very quickly). , after click next checkbox , see crashed if i'm not wait little bit after last ajax call.

how can check when ajax finish , release php file mysql query ?

i try delay(800).hide(0) way guess time enough or not ??

$.ajax({

            type: "post",              url: "boxsave.php",              data: { genbox: idcheck, liczba: "0" },             datatype:'json';             success: function(msg){              } 

});

add datatype:'json' in ajax

in boxsave.php file add echo json_encode('success'); after success of mysql query.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -