jquery Ajax请求中显示Loading...


jquery Ajax请求中显示Loading...

$('#btnTest').click(function(){
     $.ajax({
          url ---- ,根据你需要设置url路径
          type:'post',
          data:'name=Test',
          timeout:15000,
          beforeSend:function(XMLHttpRequest){
              //alert('远程调用开始...');
              $("#loading").html.("<img src='/jquery/images/loading.gif' />");

       //显示文字 $("#loading").html.("<img src='/jquery/images/loading.gif' />");
         },
         success:function(data,textStatus){
             alert('开始回调,状态文本值:'+textStatus+' 返回数据:'+data);
             // $("#loading").empty();
           },
          complete:function(XMLHttpRequest,textStatus){
              // alert('远程调用成功,状态文本值:'+textStatus);
             $("#loading").empty();
           },
           error:function(XMLHttpRequest,textStatus,errorThrown){
              alert('error...状态文本值:'+textStatus+" 异常信息:"+errorThrown);
             $("#loading").empty();
          }
       });
    });

<div id="loading"></div>

< input type="button" id="btnTest" value="Test">

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM