Blueimp FileUpload : fileuploadsubmit error in returning responseText

不打扰是莪最后的温柔 提交于 2019-12-13 19:11:48

问题


I'm working with the Blueimp FileUpload plugin and all is well apart from when i attempt to capture the response after the image has been uploaded:

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

    });

});

a quick glance in the developer console reveals that indeed there's a response text:

but when i attempt to grab the response: console.log(data.jqXHR.responseText);, i get a Uncaught TypeError: Cannot read property 'responseText' of undefined error.

where could i be going wrong?

来源:https://stackoverflow.com/questions/47198306/blueimp-fileupload-fileuploadsubmit-error-in-returning-responsetext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!