Reputation: 145
i need to refresh the iframe after upload ajax about 2 seconds after it shows loading div but i can't set timeout for ajaxstop function
is there any way to do this?
$('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);
}
});
Upvotes: 1
Views: 8045
Reputation: 3083
try this:
$('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);
}
});
Upvotes: 1
Reputation: 733
If you want to wait 1 second after all AJAX events complete, then you should change
setTimeout(function(){
$(document).ajaxStop(function(){
window.location.reload();
});
}, 1000);
to
$(document).ajaxStop(function(){
setTimeout(function(){
window.location.reload();
}, 1000);
});
Upvotes: 2