Methods to add additional parameters to jquery's ajaxfileupload
- 2020-03-30 02:13:10
- OfStack
Direct way:
$.ajaxFileUpload({
data:{"a":123,"b":456};//Additional parameters in json format
});
Then, in the ajaxfileupload.js file, I modify two functions, which are essentially a function (add a new argument to the function).
The first place:
createUploadForm: function(id, fileElementId,data){} Is greater than the 26 Ok.
Then add the following code to the function body:
if (data) {
for (var i in data) {
$('<input type="hidden" name="' + i + '" value="' + data[i] + '" />').appendTo(form);
}
}
What the code does: work with json data, adding type='hidden' input to the form form
The second section:
ajaxFileUpload(){}
var form = jQuery.createUploadForm(id, s.fileElementId,s.data); Modify this line, just add one more parameter to it.
This modification is actually about the parameters of the function call.