jquery file upload module sending extra parameter

对着背影说爱祢 提交于 2019-12-11 11:44:47

问题


I'm using jquery file upload plugin. I added an extra button to tell the server to finalize everything, this is suppose to send an extra parameter as below:

$('.btn-finalize').click(function(){
    $('#fileupload').fileupload({
        dataType:'json',
        formData:{name:'finalize',value:'1'},
        url: 'server/php/'
       });
});

This click handler is called, but no request is getting sent. why?


回答1:


The documentation advice to inverse click and autoupload handlers.

$('#fileupload').fileupload({
    autoUpload: false,
    formData: {
        name: 'finalize',
        value: '1'
    },
    add: function (e, data) {
        $('.btn-finalize').click(function () {
            data.submit();
        })
    },
    done: function (e, data) {    
        console.log(data.formData.name); // Show "finalize" in the console
    }
});

A testing fiddle



来源:https://stackoverflow.com/questions/21465578/jquery-file-upload-module-sending-extra-parameter

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