18 lines
537 B
JavaScript
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));
|
|
} |