-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.js
34 lines (27 loc) · 1.19 KB
/
javascript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*jshint esversion: 6 */
const displayContainer = document.getElementById("display");
document.getElementById("btn").addEventListener('click', loadDegrees);
function loadDegrees() {
const request = new XMLHttpRequest();
request.open('GET', 'https://henrychoy.github.io/HW5/degrees.json', true);
request.onload = function () {
if (request.status === 200) {
const data = JSON.parse(request.responseText);
let htmlString = "";
for (let i=0; i < data.my_college_degrees.length; i++){
htmlString += `<tr>
<td>${data.my_college_degrees[i].School}</td>
<td>${data.my_college_degrees[i].Major}</td>
<td>${data.my_college_degrees[i].Type}</td>
<td>${data.my_college_degrees[i].Year_Complete}</td>
</tr>`
}
displayContainer.insertAdjacentHTML("beforeend", htmlString);
document.getElementById("btn").disabled = true;
}
else{
console.log("Error loading data. Please reach out to Henry Choy.")
}
}
request.send();
}