我需要在显示加载div后大约2秒后上传ajax后刷新iframe 但是我无法为ajaxstop函数设置超时
有没有办法做到这一点?
$('form').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
$("#progressbar").progressbar({
value: percentComplete
});
$('#porcentagem').html(percentVal);
if(percentComplete == 100){
$('#wait').remove();
}
},
complete: function() {
setTimeout(function(){
$('#conteudo_upload').hide();
$('#loading').show();
}, 800);
setTimeout(function(){
$(document).ajaxStop(function(){
window.location.reload();
});
}, 1000);
}
});
答案 0 :(得分:2)
如果你想在所有AJAX事件完成后等待1秒,那么你应该改变
setTimeout(function(){
$(document).ajaxStop(function(){
window.location.reload();
});
}, 1000);
到
$(document).ajaxStop(function(){
setTimeout(function(){
window.location.reload();
}, 1000);
});
答案 1 :(得分:1)
试试这个:
$('form').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
$("#progressbar").progressbar({
value: percentComplete
});
$('#porcentagem').html(percentVal);
if(percentComplete == 100){
$('#wait').remove();
}
},
complete: function() {
setTimeout(function(){
$('#conteudo_upload').hide();
$('#loading').show();
}, 800);
setTimeout(function(){
window.location.reload();
}, 1000);
}
});