Commit 9b857aa5 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch...

Merge branch 'feature-c/3972-supprimer-une-ligne-intermedaire-du-multiupload-provoque-une-erreur' into 'dev'

database.js : clean data content before submiting

See merge request !745
parents 12b996c3 0f2922bc
Pipeline #155230 passed with stages
in 13 minutes and 55 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