无法读取未定义 n.extend.each 的 属性 'length'

Cannot read property 'length' of undefined n.extend.each

我正在使用 blueimp 插件上传文件,一切正常。

但是,上传完成后,我在导航器控制台中看到了这个:

Uncaught TypeError: Cannot read property 'length' of undefined
n.extend.each @ jquery-2.1.4.min.js:2
up.find.fileupload.done @ imgdown.js:45
$.Widget._trigger @ jquery.ui.widget.js:527
$.widget._onDone @ jquery.fileupload.js:862
(anonymous function) @ jquery.ui.widget.js:127
(anonymous function) @ jquery.fileupload.js:908
j @ jquery-2.1.4.min.js:2k.fireWith @ jquery-2.1.4.min.js:2
x @ jquery-2.1.4.min.js:4k.cors.a.crossDomain.send.b @ jquery-2.1.4.min.js:4"

我想知道是否有办法解决这个问题。

代码如下:

imgdown.js

form.fileupload({
    url: form.attr('action'),
    dataType: 'html',
    done: function (e, data) {
        $.each(data.result.files, function (index, file) {
            $('<p/>').text(file.name).appendTo('#icon');
        });
    },
    progressall: function (e, data) {
        showprog( form.find('div#progress') );
        var progress = parseInt(data.loaded / data.total * 100, 10);
        up.find('#progress .progress-bar').css( 'width', progress + '%' )
            .text( progress + '%' );
    }
}).prop('disabled', !$.support.fileInput)
    .parent().addClass($.support.fileInput ? undefined : 'disabled');

data.result.files 不是数组或类数组对象。它没有 length 属性。您需要弄清楚它实际包含什么,以及为什么它不包含您认为应该包含的内容。首先查看浏览器的开发人员工具,找出响应 AJAX 请求而发送给您的值。