Blueimp multiple fileupload response parsing is wrong

时间:2017-08-04 12:40:50

标签: ajax parsing file-upload blueimp

I have a problem with blueimp multi upload after files are getting uploaded. When the table is getting repopulated on ajax response than in the table I have for all uploaded files the same delete link and thumbnail. If I reload the page than everything is ok.

Checking under network the response I see that for all checked images comes back the response separatly, but my server sends already uploaded images in a json

here is my code

$('#fileupload').fileupload(
        'option',
        'redirect',
        window.location.href.replace(
                /\/[^\/]*$/,
                '/cors/result.html?%s'
                )
        );

// Load existing files:
$('#fileupload').addClass('fileupload-processing');

$.ajax({
    // Uncomment the following to send cross-domain cookies:
    xhrFields: {withCredentials: true},
    url: '/documents/users/' + $('#profile-data').data('user-id'),
    dataType: 'json',
    context: $('#fileupload')[0],
    beforeSend: function (xhr) {
        xhr.setRequestHeader('X-CSRF-TOKEN', $('meta[name="csrf-token"]').attr('content'));
    }
}).always(function () {
    $(this).removeClass('fileupload-processing');
}).done(function (result) {
    //here I get the response
    $(this).fileupload('option', 'done')
            .call(this, $.Event('done'), {result: result});
});

}

How can be fixed this bug?

0 个答案:

没有答案