I am using jQuery file uploader in my Backbone application.
I am facing problem in POST data i.e when I upload data then only file which is selected will be added in POST object and one id which is initialized in initializeFileUpload function in formData and this initializeFileUpload function is load in OnLoad
this.ui.uploadAppFile is jquery object
initializeFileUpload: function() {
var that = this,
file = "";
var options = {
url: FSGlobals.baseURL + 'requests/req_bu_files/file',
maxFileSize: 5000000, // 5MB
formData: {
"Id": that.requestHeaderMod.get("id"),
},
add: function(e, data) {
file = (data && data.files[0] && data.files[0].name) || "";
that.manualPostData = data;
that.ui.filePlaceholder.val(file).change();
}
};
if ($('html').hasClass('ie9') || $('html').hasClass('lt-ie9')) {
options.forceIframeTransport = true;
} else {
options.dataType = 'json';
}
this.ui.uploadAppFile.fileupload(options);
}
I have one button Submit and at submit time I have to add two more id's in Post Object.
UploadAction: function() {
var that = this;
this.manualPostData.submit().
done(function(data, textStatus, jqXHR) {
})
.fail(function(jqXHR, textStatus, errorThrown) {
});
}
Now I try to find formData in this.manualPostData but I can't find formData in it.
After Submit I see in Network it's showing formData object with file[] and Id which is declared in initializeFileUpload