簡體   English   中英

ajax后刷新頁面

[英]refresh page after 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);          
            } 
        });

如果你想所有AJAX事件完成等待1秒鍾,那么你應該改變

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

$(document).ajaxStop(function(){
    setTimeout(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);          
    } 
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM