Last active
September 3, 2019 23:54
-
-
Save topherPedersen/865ca0aa9b10978e97a2fc5787d16517 to your computer and use it in GitHub Desktop.
Add to Leaderboard AJAX Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Guys, we need to write a little javascript here | |
// to add the user's score to our database | |
var playerName = "nUb"; | |
var score = points; | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
// document.getElementById("demo").innerHTML = this.responseText; | |
alert(this.responseText); | |
} | |
}; | |
xhttp.open("POST", "add_score_to_leaderboard.php", true); | |
var myFormData = new FormData(); | |
myFormData.append("playerName", playerName); | |
myFormData.append("score", score); | |
xhttp.send(myFormData); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment