inf03-06.2022-z2/js/post.js

27 lines
686 B
JavaScript
Raw Permalink Normal View History

2024-11-13 13:47:17 +00:00
document.addEventListener('DOMContentLoaded', () => {
button_dodaj = document.getElementById("button_dodaj")
button_dodaj.addEventListener("click", () => {
data = {
nazwa: document.getElementById("name").value,
cena: document.getElementById("price").value
}
fetch("php/post.php", {
method: "POST",
headers: {
"Content-Type":"application/json",
},
body: JSON.stringify(data)
})
.then(response => response.json)
.then(data => {
console.log("Succes", data)
window.location.reload()
})
})
})