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