File size: 718 Bytes
18bc40b
 
 
 
 
 
 
 
 
5d67474
18bc40b
 
 
5d67474
18bc40b
 
 
 
 
 
 
 
5d67474
18bc40b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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.");
    });
});