1

我需要在显示加载 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);          
            } 
        });
4

2 回答 2

2

如果您想在所有 AJAX 事件完成后等待 1 秒,那么您应该更改

setTimeout(function(){
    $(document).ajaxStop(function(){
        window.location.reload();
    }); 
}, 1000);  

$(document).ajaxStop(function(){
    setTimeout(function(){
        window.location.reload();
    }, 1000);
});
于 2013-07-23T06:39:16.230 回答
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);          
    } 
});
于 2013-07-23T06:42:13.817 回答