简体   繁体   English

发送加载程序错误之前的ajax

[英]ajax before send loader error

i am sending ajax request with drop down change, and showing a loader div using before send, now error is this the loader only shows for first time but ajax is working all the time 我正在发送带有下拉更改的ajax请求,并在发送之前使用div显示加载程序div,现在错误是此加载程序仅首次显示,但ajax一直在工作

Website is live, you can check live 网站是实时的,您可以实时查询

go to http://doctorsnearu.com/ choose city choose specialization, then click find dr. 转到http://doctorsnearu.com/选择城市选择专业化,然后单击查找博士。 you will me moved to new page now change your search using drop downs.. you will see the loader for the first time but not after that.. but ajax will work.. 您将我移至新页面,现在使用下拉菜单更改搜索。.您将首次看到加载程序,但此后不会。.但是ajax可以使用。

my code is 我的代码是

$(document).ready(function(){
$('[data-load="again"]').click(function(e) {

     var a=$(this).val();

     var b=$(this).attr('data-type');


  $.ajax({
   type: "POST",
   url: "gve_dr.php",
   data: "val="+a+"&type="+b,
   success: function(html){

         //alert(html);
         //response frm php file

   $("#load_drs").html(html);

   },

   beforeSend:function()
   {
    $("#olay").css('display','block');
//#olay is the div containing loader
   }
  });
     return true;
 });
});

// JavaScript Document // JavaScript文档

//#olay is the div containing loader //#olay是包含加载程序的div

can any body help me 有谁能够帮助我

move this 移动这个

$("#olay").css('display','block'); //#olay is the div containing loader 

before the $.ajax() is called, that means the div will show once you click the button. 在调用$ .ajax()之前,这意味着div将在您单击按钮后显示。

and then add this 然后添加

   complete: function() { 
       $("#olay").css('display','none');
   }

to your ajax method options. 您的ajax方法选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM