问题
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