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 @@ ...@@ -50,7 +50,7 @@
<body> <body>
<h1> OUCÉQUECÉ</h1> <h1> OUCÉQUECÉ</h1>
<h2>Quel est ton nom ?</h2> <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> <input type="text" id="nom" name="name" required>
<br> <br>
<button type="submit">Envoyer</button> <button type="submit">Envoyer</button>
...@@ -66,40 +66,39 @@ ...@@ -66,40 +66,39 @@
</body> </body>
<script> <script>
document.getElementById('nom').addEventListener('submit', transmission() )
const name = document.getElementById('name').value; document.getElementById("form").addEventListener("submit", transmission);
const jsonData = { async function transmission(event) {
"username": name event.preventDefault();
}; const name = document.getElementById('nom').value;
const jsonData = {
async function transmission() { "username": name
const Jsondata = { };
username:name
};
try {
try { const response = await fetch("http://localhost:8080/projet_prog_reseau_war_exploded/api/start", {
const response = await fetch("http://localhost:8080/projet_prog_reseau_war_exploded/api/start", { method: "POST",
method: "POST", headers: {
headers: { "Content-Type": "application/json",
"Content-Type": "application/json", },
}, body: JSON.stringify(jsonData),
body: JSON.stringify(Jsondata), });
});
if (!response.ok) {
if (!response.ok) { throw new Error(`Erreur HTTP : ${response.status}`);
throw new Error(`Erreur HTTP : ${response.status}`); }
}
const responsejson = await response.json();
const responsejson = await response.json();
localStorage.setItem("transferdata", JSON.stringify(responsejson));
localStorage.setItem("transferdata", JSON.stringify(responsejson)); window.location.href = "http://localhost/frontend/Front.html";
window.location.href = "front.html";
} catch (error) { } catch (error) {
console.error("Erreur : ", error); console.error("Erreur : ", error);
document.getElementById("response").textContent = `Erreur : ${error.message}`; }
} }
}
</script>
</script> </script>
</html> </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