function sendBacheca() { var object = document.querySelector('#object').value; var body = document.querySelector('#body').value; $.ajax({ type: "POST", url: "php/bacheca/send_new_bacheca.php", data: { object: object, body: body }, success: function (res) { if (res === 'error') { Swal.fire({ type: 'error', text: 'Errore: ' + res }); } else { Swal.fire({ type: 'success', title: 'Pubblicazione inserita con successo!', showConfirmButton: false, timer: 2000 }); //Allegati var fd = new FormData(); for (i = 0; i <= 10; i++) { var files = document.querySelector('#ticket_attachments').files[i]; // Check file selected or not fd.append('file' + i, files); } $.ajax({ url: 'php/bacheca/attachments_upload.php', type: 'post', data: fd, dataType: 'json', contentType: false, processData: false, success: function (response) { if (response.status == 1) { var extension = response.extension; var path = response.path; } else { alert('File not uploaded'); } } }); document.querySelector('#close_new_bacheca').click(); openBacheca(); } } }); } function deleteBacheca(id) { Swal.fire({ title: "Eliminare la pubblicazione?", showDenyButton: false, showCancelButton: true, confirmButtonText: "Elimina", denyButtonText: `No` }).then((result) => { if (result.value == true) { $.ajax({ type: "POST", url: "php/bacheca/delete_bacheca.php", data: { id: id }, success: function (res) { if (res === 'error') { Swal.fire({ type: 'error', text: 'Errore: ' + res }); } else { Swal.fire({ type: 'success', title: 'Pubblicazione eliminata con successo!', showConfirmButton: false, timer: 2000 }); openBacheca(); } } }); } }); }