Blueimp FileUpload:返回responseText时出现fileuploadsubmit错误

时间:2017-11-09 09:34:26

标签: jquery file-upload blueimp

我正在使用Blueimp FileUpload插件,所有这些都与我尝试在图像上传后捕获响应时完全不同:

var fi = $('#fileupload'); //file input 
    var process_url = '/backoffice/listings/upload-images ';
    var progressBar = $('<div/>').addClass('progress').append($('<div/>').addClass('progress-bar')); //progress bar
    var uploadButton = $('<button/>').addClass('button btn-blue upload').text('Upload');    //upload button

    uploadButton.on('click', function () {
        var $this = $(this), data = $this.data();
         data.submit().always(function () {
                $this.parent().find('.progress').show();
                $this.parent().find('.remove').remove();
                $this.remove();
        });
    });

      fi.fileupload({
            url: process_url,
            dataType: 'json',
            autoUpload: false,
            acceptFileTypes: /(\.|\/)(gif|jpe?g|png|mp4|mp3)$/i,
            maxFileSize: 1048576, //1MB
            disableImageResize: /Android(?!.*Chrome)|Opera/ 
            .test(window.navigator.userAgent),
            previewMaxWidth: 50,
            previewMaxHeight: 50,
            previewCrop: true,
            dropZone: $('#dropzone')
    });

   //other functions work fine

   //Code which needs to comes after submit 
   fi.on('fileuploadsubmit', function (e, data) {    
        console.log('submit');
        console.log(data);

    });

});

在开发者控制台中快速浏览一下,确实有一个响应文本:

developer console

但是当我尝试抓取回复:console.log(data.jqXHR.responseText);时,我收到Uncaught TypeError: Cannot read property 'responseText' of undefined错误。

我哪里可能出错?

0 个答案:

没有答案