我有一個「處理...」div覆蓋圖,在製作ajax調用之前用$('')。show()顯示並在完成時隱藏。我遇到的問題是,如果我想要顯示div,然後再次隱藏div之前進行幾次ajax調用,它似乎將事件排入Internet Explorer(7)和Chrome(2.0.172.39),但是我在Firefox中獲得預期的結果(3.0.13)。當有一個單一的Ajax調用它工作正常。代碼是這樣的:在Internet Explorer/Chrome中延遲JQuery show()
<div id="foo">processing...</div>
<button onclick="performSingle()" /> <-- This behaves like it's supposed to
<button onclick="performMultiple()" /> <-- This queues the events in IE/Chrome.
<script>
$(document).ready(function(){
$('#foo').hide();
});
function singleAjaxCall() {
$.ajax({
url: ...,
type: "GET",
async: false, //There is a reason for this.
success: function() {}
});
}
function multipleAjaxCalls() {
singleAjaxCall();
singleAjaxCall();
singleAjaxCall();
singleAjaxCall();
singleAjaxCall();
singleAjaxCall();
singleAjaxCall();
singleAjaxCall();
}
function performSingle(){
$('#foo').show();
singleAjaxCall();
$('#foo').hide();
}
function performMultiple(){
$('#foo').show();
multipleAjaxCalls();
$('#foo').hide();
}
</script>
如果您已經完成了傳遞'0'的操作,那麼'function'會被忽略。 – 2009-09-09 15:51:40
現在是。謝謝 – 2009-09-10 08:02:17