I have been suffering for what time it is over a simple question When filling out the field, an AYAX request is automatically sent with a long upload. I want to launch a preloader at this time and try the following:

<script> $("#visiting_object").change(function(){ if($(this).val() == 248399) { alert("тест"); return true; } else { $("#datepicker10").blur(function() { $.ajax({ type: 'post', url: 'Testdirect.php', data: $('.passegAdd').serialize(), beforeSend: function() { $('#loading').show(); }, complete: function() { $('#loading').hide(); } success: function (result) { $('#request').html( result ); console.log(result); /* alert("У вас количество заявок больше 5"); document.getElementById("button34").style.display="none";*/ } }); return true; }); } }); </script> 
  <div id="loading" name="loading" class="windows8"> <div class="wBall" id="wBall_1"> <div class="wInnerBall"></div> </div> <div class="wBall" id="wBall_2"> <div class="wInnerBall"></div> </div> <div class="wBall" id="wBall_3"> <div class="wInnerBall"></div> </div> <div class="wBall" id="wBall_4"> <div class="wInnerBall"></div> </div> <div class="wBall" id="wBall_5"> <div class="wInnerBall"></div> </div> </div> </div> 

What could be wrong here, even I don’t understand ((Please tell me

  • At a minimum, the fact that you create a blur event in the change event. What time do you want to show the loader? When you change the value or when you lose focus? - Stepan Kasyanenko
  • @StepanKasyanenko During the loss of focus - Yevgeny Pivovarov
  • Well, then take out the announcement of the loss of focus event from the change event. - Stepan Kasyanenko
  • @StepanKasyanenko Delivers, but it seems to me that this is not the case - Evgeny Pivovarov
  • Show what you got. Edit the question. Then tell me what's not working now. And provide html for #datepicker10 . - Stepan Kasyanenko

0