-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson.html
43 lines (37 loc) · 908 Bytes
/
json.html
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
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<script type="text/javascript">
var ajax = new XMLHttpRequest();
var file = "/school/public/assets/json/links.json";
ajax.onreadystatechange = function(){
//alert("readyState: " + ajax.readyState + " response: " + ajax.status)
if (ajax.readyState == 4 && ajax.status == 200){
showSites(ajax.responseText);
}
}
function showSites(data){
//alert(data);
var obj = JSON.parse(data);
var output = "";
for (var i=0; i<obj.sites.length; i++) {
output += "<a href='" + obj.sites[i].url + "'>" + obj.sites[i].display + "</a><br>";
}
document.getElementById("output").innerHTML = output;
}
ajax.open("GET", file, true);
ajax.send();
</script>
<style type="text/css">
.tutorial {
}
</style>
</head>
<body >
<h1>Homework Assignments(JSON List)</h1>
<div class="tutorial" id="output">
</div>
</body>
</html>