1

我试图展示由 jQuery 表单插件处理的上传进度,正如他们在他们的网站上演示的那样。无论我尝试什么,我都无法显示上传进度的百分比,并且[jquery.form] state = uninitialized在文件上传时,Firebug 会显示在控制台中。上传完成后,Firebug 显示[jquery.form] state = loading jquery.form.js (line 904) [jquery.form] isXml=false

这是我的 Javascript。后端使用 class.upload.php、www.verot.net/php_class_upload.htm,完成后返回 JSON。

$("#apparatusPhotoUpload").ajaxForm({
    beforeSend: function() {
        //Do things such as disable upload button, switch to default preview image
    },
    uploadProgress: function(event, position, total, percentComplete) {
        var progress = percentComplete;
        $("#uploadProgress").html(progress);
    },
    dataType: 'json',
    success: function(data) {
        //Fire a couple of functions that alter data in the DOM
    }

任何帮助,将不胜感激!

4

2 回答 2

1

GitHub解决方案: 使用空白文件输入的永无止境的循环(包括补丁)

根据malsup评论

Added proposed fix to v2.91.

下载jQuery.form.js 版本 3.50

问题为我解决了。

于 2014-05-08T09:10:14.267 回答
0

我认为新插件修复了一些相关的错误。我遇到了类似的问题,但我能够通过安装最新版本的jQuery Form Plugin(版本:3.26.0-2013.01.28)并在我的 javascript 中使用类似的东西(适用于您的示例)来使其工作:

$("#apparatusPhotoUpload").ajaxForm({
    beforeSubmit: function() {
        //Do things such as disable upload button
        var progress_bar = $('<div class="progress"><div class="bar" style="width:0;"></div></div>');
        progress_bar.appendTo("#apparatusPhotoUpload");
    },
    uploadProgress: function(event, position, total, percentComplete) {
        var percentVal = percentComplete + '%';
        $('.bar').width(percentVal);
    },
    dataType: 'json',
    success: function(responseText, statusText, xhr, form) {
        //Fire a couple of functions that alter data in the DOM to show responseText
}
于 2013-02-04T22:33:05.973 回答