0

问题:

在进度条完成后但在 setTimeout() 启动之前将文本附加到 div。

HTML 代码:

<div id="loading" class="files"></div>

jQuery代码:

<script>    
    $(function () {
        'use strict';
        // Server-side upload handler:
        var url = 'process.php';

        $('#fileupload').fileupload({
            url: url,
            autoUpload: true,
            acceptFileTypes: /(\.|\/)(txt)$/i,
            maxFileSize: 5000000, // 5 MB
            done: function (e, data) {
                setTimeout(function(){
                    window.location = "explorer.php";}, 2000);
            },
            progressall: function (e, data) {
                var progress = parseInt(data.loaded / data.total * 100, 10);
                $('#progress .progress-bar').css(
                    'width',
                    progress + '%'
                );
            }
        }).prop('disabled', !$.support.fileInput)
            .parent().addClass($.support.fileInput ? undefined : 'disabled');
    });
</script>

期望的结果:

进度条达到 100% 后,将文本“Loading ...”附加到 div,然后启动 setTimeout()。

4

1 回答 1

1

done 方法应该具有执行此操作的代码。所以你的完成会变成,

progressall: function (e, data) {
                var progress = parseInt(data.loaded / data.total * 100, 10);
                $('#progress .progress-bar').css(
                    'width',
                    progress + '%'
                );
                if (progress == 100)
                    $("#loading").html("Loading...");
            }

但是文本“Loading...”只会向用户显示几秒钟,因为我们在 2 秒后启动了页面刷新。

于 2013-10-23T07:24:53.190 回答