mirror of
https://git.roussel.pro/telecom-paris/pact.git
synced 2026-02-09 10:30:17 +01:00
intégration formulaire avec l'api
This commit is contained in:
21
code/formulaire/main.js
Normal file
21
code/formulaire/main.js
Normal file
@@ -0,0 +1,21 @@
|
||||
document.getElementById("form").addEventListener("submit", function (event) {
|
||||
let payload = {}
|
||||
event.preventDefault();
|
||||
let data = new FormData(event.target);
|
||||
data.append("note", parseInt(document.getElementById("note-range").value))
|
||||
data.append("source","website")
|
||||
let urlEncoded = new URLSearchParams(Object.fromEntries(data.entries()))
|
||||
fetch("http://localhost:8080/add_review", {
|
||||
method: "POST",
|
||||
headers:{
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: urlEncoded
|
||||
}).then(res => {
|
||||
document.location = "/merci.html";
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById("note-range").addEventListener("input", function (event) {
|
||||
document.getElementById("note-display").innerHTML = event.target.value;
|
||||
});
|
||||
Reference in New Issue
Block a user