最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - refresh page after ajax - Stack Overflow

programmeradmin1浏览0评论

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();

            }
        },
        plete: function() {
            setTimeout(function(){
                $('#conteudo_upload').hide();
                $('#loading').show(); 
            }, 800);

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

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();

            }
        },
        plete: function() {
            setTimeout(function(){
                $('#conteudo_upload').hide();
                $('#loading').show(); 
            }, 800);

    setTimeout(function(){
        $(document).ajaxStop(function(){
            window.location.reload();
        }); 
    }, 1000);          
            } 
        });
Share Improve this question asked Jul 23, 2013 at 6:35 Eddie D.Eddie D. 1453 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

If you want to wait 1 second after all AJAX events plete, then you should change

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

to

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

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();

        }
    },
    plete: function() {
        setTimeout(function(){
            $('#conteudo_upload').hide();
            $('#loading').show(); 
        }, 800);

        setTimeout(function(){
               window.location.reload();
        }, 1000);          
    } 
});
发布评论

评论列表(0)

  1. 暂无评论