kelompok06-2048/Score_Request.js
Evelyn Sucitro b7db68222c Update
2025-12-01 13:52:13 +07:00

18 lines
537 B
JavaScript

function saveScore(score) {
fetch('Score.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'score=' + encodeURIComponent(score)
})
.then(response => response.json())
.then(data => {
if (data.status === "success") {
console.log("Skor berhasil disimpan!");
} else {
console.log("Gagal menyimpan skor:", data.message);
}
})
.catch(error => console.error("Error API:", error));
}