2017-05-30 06:52:58 +00:00
|
|
|
/* AJAX Tutorial, By The Net Ninja
|
|
|
|
https://www.youtube.com/watch?v=h0ZUpPiV1ac
|
|
|
|
*/
|
|
|
|
|
|
|
|
window.onload = function(){
|
|
|
|
|
2017-06-15 06:14:57 +00:00
|
|
|
const serverPath = "https://server.figytuna.com:8080/ali/hello/";
|
|
|
|
const pages = [
|
2017-06-15 06:21:00 +00:00
|
|
|
"World",
|
|
|
|
"Data",
|
|
|
|
"Players",
|
|
|
|
"Location"
|
2017-06-15 06:14:57 +00:00
|
|
|
]
|
|
|
|
//Generate HTML table
|
2017-06-15 06:27:45 +00:00
|
|
|
for (const pagePath of pages){
|
2017-06-15 06:14:57 +00:00
|
|
|
//Adds new table row based on the data request
|
|
|
|
const $newTableRow = $("<tr>"
|
|
|
|
+ "<td>Hello " + pagePath + "</td>"
|
2017-06-15 06:21:00 +00:00
|
|
|
+ "<td id=\"hello-"+ pagePath.toLowerCase() + "\"></td>"
|
2017-06-15 06:14:57 +00:00
|
|
|
+ "</tr>");
|
|
|
|
|
|
|
|
//Appends new table row to table
|
|
|
|
$("#hello-table").after($newTableRow);
|
2017-05-30 06:52:58 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 06:14:57 +00:00
|
|
|
//Gets Table data from server
|
2017-06-15 06:27:45 +00:00
|
|
|
for (const pagePath of pages){
|
2017-06-15 06:21:00 +00:00
|
|
|
$.get(serverPath + pagePath.toLowerCase(), function(data){
|
2017-06-15 06:27:45 +00:00
|
|
|
console.log(pagePath + "|" + data);
|
2017-06-15 06:21:00 +00:00
|
|
|
document.getElementById("hello-" + pagePath.toLowerCase()).innerHTML = data;
|
2017-06-15 06:14:57 +00:00
|
|
|
});
|
|
|
|
}
|
2017-05-30 06:52:58 +00:00
|
|
|
}
|