const params = [ ['dluo', 'DLUO', true], ['lot', 'Nº de lot', true], ['qty', 'Poids net (g)', true], ['teneur', 'Teneur en fruits (%)', false], ['fruit', 'Quantité de fruits pour 100g (g)', false], ] function post() { const lemot = $('input[type=password]').val(); const formdata = new FormData($('form')[0]); formdata.append('lemotdepasse', lemot); $.ajax({ url: backend_api + `newtikette`, type: 'POST', data: formdata, contentType: false, processData: false, xhr: function () { var myXhr = $.ajaxSettings.xhr(); if (myXhr.upload) { // For handling the progress of the upload myXhr.upload.addEventListener('progress', function (e) { if (e.lengthComputable) { $('progress').attr({ value: e.loaded, max: e.total, }); } }, false); } return myXhr; } }) .then(data => { console.log(data); }) .catch(err => { console.log(err); if (err.status == 403) { M.toast({html: 'access denied'}); } else if (err.status == 500) { M.toast({html: 'server error'}); } }) .always(() => { $('.progress').hide(); $('.btn').removeClass('disabled'); }); } $(document).ready(async () => { const appbody = $("#appbody"); const block = $('
'); block.append($(`
`)); block.append($(`
`)); const subst = $('