for of, not for in. Dang javascript

This commit is contained in:
alisolarflare 2017-06-14 23:21:00 -07:00
parent 6a81961f59
commit b83668a398

View file

@ -6,17 +6,17 @@ window.onload = function(){
const serverPath = "https://server.figytuna.com:8080/ali/hello/"; const serverPath = "https://server.figytuna.com:8080/ali/hello/";
const pages = [ const pages = [
"world", "World",
"data", "Data",
"players", "Players",
"location" "Location"
] ]
//Generate HTML table //Generate HTML table
for (pagePath in pages){ for (pagePath of pages){
//Adds new table row based on the data request //Adds new table row based on the data request
const $newTableRow = $("<tr>" const $newTableRow = $("<tr>"
+ "<td>Hello " + pagePath + "</td>" + "<td>Hello " + pagePath + "</td>"
+ "<td id=\"hello-"+ pagePath + "\"></td>" + "<td id=\"hello-"+ pagePath.toLowerCase() + "\"></td>"
+ "</tr>"); + "</tr>");
//Appends new table row to table //Appends new table row to table
@ -24,9 +24,9 @@ window.onload = function(){
} }
//Gets Table data from server //Gets Table data from server
for (pagePath in pages){ for (pagePath of pages){
$.get(serverPath + pagePath, function(data){ $.get(serverPath + pagePath.toLowerCase(), function(data){
document.getElementById("hello-" + pagePath).innerHTML = data; document.getElementById("hello-" + pagePath.toLowerCase()).innerHTML = data;
}); });
} }
} }