dilemmas / script.js
gk2410's picture
Update script.js
18bc40b verified
raw
history blame contribute delete
718 Bytes
document.getElementById("submit").addEventListener("click", function() {
let dilemma = document.getElementById("dilemma").value;
if (dilemma.trim() === "") {
alert("Please enter a dilemma.");
return;
}
fetch("/solve_dilemma", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ dilemma: dilemma })
})
.then(response => response.json())
.then(data => {
document.getElementById("solution").innerText = "Solution: " + data.solution;
})
.catch(error => {
console.error("Error:", error);
alert("Something went wrong! Check the console for details.");
});
});