ajax之后刷新页面
我需要在显示加载div后上传ajax大约2秒后刷新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); } });
试试这个:
$('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); } });
如果你想在所有AJAX事件完成后等待1秒钟,那么你应该改变
setTimeout(function(){ $(document).ajaxStop(function(){ window.location.reload(); }); }, 1000);
至
$(document).ajaxStop(function(){ setTimeout(function(){ window.location.reload(); }, 1000); });