Implementazione form aggiunta
This commit is contained in:
14
script.js
14
script.js
@@ -84,7 +84,7 @@ function editPizza(id){
|
||||
}
|
||||
}
|
||||
|
||||
function addPizza(nome, id, prezzo){
|
||||
function addPizza(id, nome, prezzo){
|
||||
const myHeaders = new Headers();
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
|
||||
@@ -105,10 +105,20 @@ function addPizza(nome, id, prezzo){
|
||||
.then((response) => response.text())
|
||||
.then((result) => {
|
||||
alert("Pizza aggiunta con successo!");
|
||||
listPizze();
|
||||
window.close();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
alert("Errore nell'aggiunta, controllare la console per dettagli sull'errore.");
|
||||
});
|
||||
}
|
||||
|
||||
function handleAddPizza(event){
|
||||
event.preventDefault();
|
||||
|
||||
const nome = document.getElementById("name").value;
|
||||
const id = document.getElementById("id").value;
|
||||
const prezzo = document.getElementById("price").value;
|
||||
|
||||
addPizza(id, nome, prezzo);
|
||||
}
|
||||
Reference in New Issue
Block a user