jquery Ajax请求中显示Loading...

jquery Ajax请求中显示Loading...html

$('#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' />");jquery

       //显示文字 $("#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();
          }
       });
    });ajax

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

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

url