I have attachment form with dropzonejs file upload and note field and need to send those both fields data to my server on jQuery AJAX form submit.
Attachment HTML Form code
<form id="addAttachmentForm" method="post" enctype="multipart/form-data" novalidate="novalidate">
<div class="modal-body">
<div class="companyAttachment box__input dz-clickable"
</div>
<textarea class="form-control resizeNone" name="Note" placeholder="Your note here" rows="5"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary btn-Attachment" id="add-attachment">ADD ATTACHMENT</button>
</div>
JS Code
$(document).on('submit', '#addAttachmentForm',function(e) {
e.preventDefault();
$.ajax({
type: 'POST',
url: '/attachment/store',
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
beforeSend: function () {
},
success: function(response)
{
// contactDropzone.processQueue();
},
error: function (data) {
}
});});
Dropzone.autoDiscover = false;
var contactDropzone = $('.companyAttachment').dropzone({
url: null,
paramName: 'file',
addRemoveLinks: true,
maxFiles: 1,
autoProcessQueue: false,
maxFilesize: 2,
acceptedFiles: 'image/*,application/pdf',
init: function(){
this.on("addedfile", function(file, data) {
});
}});
I set the default value of autoProcessQueue is false, but I'm confused about when I need to call contactDropzone.processQueue() method to work for AJAX form submission? or please suggest me any other better ways to POST attachment and note fields data on jQuery AJAX form submission.