Commit 0f2922bc authored by marc duez's avatar marc duez

database.js : clean data content before submiting

operation on the form can create some artefact we need to remove before submit
parent 12b996c3
Pipeline #153431 passed with stages
in 12 minutes and 57 seconds
...@@ -593,13 +593,22 @@ Database.prototype = { ...@@ -593,13 +593,22 @@ Database.prototype = {
if ( document.getElementById('upload_form') ){ if ( document.getElementById('upload_form') ){
$('#upload_form').on('submit', function(e) { $('#upload_form').on('submit', function(e) {
e.preventDefault(); e.preventDefault();
//clear empty values before submiting data
var upload_form = $('#upload_form').serializeObject()
if ("file" in upload_form)
upload_form.file = upload_form.file.filter(function(el) {
return typeof el != "object" || Array.isArray(el) || Object.keys(el).length > 0;
});
var data = JSON.stringify(upload_form)
$.ajax({ $.ajax({
type : "POST", type : "POST",
cache: false, cache: false,
crossDomain: true, crossDomain: true,
xhrFields: {withCredentials: true}, xhrFields: {withCredentials: true},
url : $(this).attr('action'), url : $(this).attr('action'),
data : {'data': JSON.stringify($('#upload_form').serializeObject())}, data : {'data': data},
success : function(result) { success : function(result) {
var js = self.display_result(result) var js = self.display_result(result)
var id, fileSelect, files, file, filename; var id, fileSelect, files, file, filename;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment