Skip to content
Snippets Groups Projects
Commit e7e3473a authored by romain's avatar romain
Browse files

correction d'erreurs

parent 33a165bc
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,7 @@
<body>
<h1> OUCÉQUECÉ</h1>
<h2>Quel est ton nom ?</h2>
<h3><form action="home.html" method="post">
<h3><form id="form" method="post">
<input type="text" id="nom" name="name" required>
<br>
<button type="submit">Envoyer</button>
......@@ -66,40 +66,39 @@
</body>
<script>
document.getElementById('nom').addEventListener('submit', transmission() )
const name = document.getElementById('name').value;
const jsonData = {
"username": name
};
async function transmission() {
const Jsondata = {
username:name
};
try {
const response = await fetch("http://localhost:8080/projet_prog_reseau_war_exploded/api/start", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(Jsondata),
});
if (!response.ok) {
throw new Error(`Erreur HTTP : ${response.status}`);
}
const responsejson = await response.json();
localStorage.setItem("transferdata", JSON.stringify(responsejson));
window.location.href = "front.html";
} catch (error) {
console.error("Erreur : ", error);
document.getElementById("response").textContent = `Erreur : ${error.message}`;
}
}
</script>
document.getElementById("form").addEventListener("submit", transmission);
async function transmission(event) {
event.preventDefault();
const name = document.getElementById('nom').value;
const jsonData = {
"username": name
};
try {
const response = await fetch("http://localhost:8080/projet_prog_reseau_war_exploded/api/start", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(jsonData),
});
if (!response.ok) {
throw new Error(`Erreur HTTP : ${response.status}`);
}
const responsejson = await response.json();
localStorage.setItem("transferdata", JSON.stringify(responsejson));
window.location.href = "http://localhost/frontend/Front.html";
} catch (error) {
console.error("Erreur : ", error);
}
}
</script>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment