1
是否有可能檢查內容是否在ajax調用中完全加載,然後顯示一些div。直到內容沒有完全加載的div不應該顯示,內容後,div必須顯示使用jQuery?查看ajax調用中的內容
是否有可能檢查內容是否在ajax調用中完全加載,然後顯示一些div。直到內容沒有完全加載的div不應該顯示,內容後,div必須顯示使用jQuery?查看ajax調用中的內容
的答案是基於總的假設,還定義了一個錯誤回調
$.ajax({
url: "/path/to/server",
type: 'POST',
data: data,
success: function(data){ <-- the success is called upon successful completion
//do something with data
$("#divID").html(data);
$("#divID").show(); <-- assumed the div was hidden initially
},
error:function(jxhr){
if(typeof(console)!='undefined'){
console.log(jxhr.status+"--"+jxhr.responseText);
}
}
});
使用jQuery ajax call success callback。它只會在完成請求後纔會觸發:
$.ajax({
type: "GET",
url: "some.html",
success: function(data){
// show my div here
$('#mydivid').html(data).show();
}
});
「內容滿載」是什麼意思?內容是什麼?每個Ajax方法都接受一次收到響應後執行的成功回調。 –
@Felix我有圖像的內容和圖像加載在Ajax。我正在計算div的高度,當完整的內容到來時,我將展示一個div。謝謝 – Harry