Learned AJAX, sticking it into sandbox.html

SHITS GETTING DOOOONNNNE
This commit is contained in:
alisolarflare 2017-05-30 02:52:58 -04:00
parent e24268fcd0
commit 8f8bf381ab
4 changed files with 78 additions and 5 deletions

19
data/players.json Normal file
View file

@ -0,0 +1,19 @@
{
"players" : [
{
"name": "Ali",
"color": "blue",
"permissions": ["mod", "dev", "op"]
},
{
"name": "Byz",
"color": "grey",
"permissions": ["builder"]
},
{
"name": "iie",
"color": "red",
"permissions" : ["admin", "mod", "dev", "op"]
}
]
}

View file

@ -1,13 +1,15 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8">
<title>Chromagaming Civilization Screen</title> <title>Chromagaming Civilization Screen</title>
</head> </head>
<body> <body>
<nav>
<a href="./index.html">Main</a>
<a href="./sandbox.html">Sandbox</a>
</nav>
<h1>The Civilization Screen</h1> <h1>The Civilization Screen</h1>
<p>Welcome to the civlization screen.</p> <p>Welcome to the civilization screen.</p>
<br />
<h2>Map</h2>
<h2>Login</h2>
</body> </body>
</html> </html>

17
sandbox.html Normal file
View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Developer's Sandbox</title>
<script src="./sandbox/helloajax.js" type="text/javascript">
</script>
</head>
<body>
<nav>
<a href="./index.html">Main</a>
<a href="./sandbox.html">Sandbox</a>
</nav>
<h1>Developer's Sandbox</h1>
</body>
</html>

35
sandbox/helloajax.js Normal file
View file

@ -0,0 +1,35 @@
/* AJAX Tutorial, By The Net Ninja
https://www.youtube.com/watch?v=h0ZUpPiV1ac
*/
window.onload = function(){
let http = new XMLHttpRequest();
http.onreadystatechange = function(){
const finalState = 4;
const idealStatus = 200;
if(http.readyState == finalState && http.status == idealStatus){
console.log(JSON.parse(http.response));
}
}
const method = "GET";
const filepath = "data/players.json";
const isASYNC = true;
http.open(method, filepath, isASYNC);
http.send();
}
/* READY STATES
0 - Request not initialized
1 - Request has been set up
2 - Request has been sent
3 - Request is in process
4 - Request is complete
*/