Learned AJAX, sticking it into sandbox.html
SHITS GETTING DOOOONNNNE
This commit is contained in:
parent
e24268fcd0
commit
8f8bf381ab
4 changed files with 78 additions and 5 deletions
19
data/players.json
Normal file
19
data/players.json
Normal 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"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
12
index.html
12
index.html
|
@ -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
17
sandbox.html
Normal 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
35
sandbox/helloajax.js
Normal 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
|
||||||
|
|
||||||
|
*/
|
Loading…
Reference in a new issue