-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
45 lines (35 loc) · 1.11 KB
/
index.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
44
45
<html>
<body>
<form id="jsonFile" name="jsonFile" enctype="multipart/form-data" method="post">
<fieldset>
<h2>Json File</h2>
<!--<input type='file' id='fileinput'>-->
<input type='button' id='btnLoad' value='Load' onclick='receivedText();'>
<ul id="conteudo">
</ul>
</fieldset>
</form>
<script type="text/javascript">
function receivedText() {
var request = new XMLHttpRequest();
request.open("GET", "./json/esporte.json", true);
request.send(null);
request.onreadystatechange = function() {
if ( request.readyState === 4 && request.status === 200 ) {
var my_JSON_object = JSON.parse(request.responseText);
console.log(my_JSON_object);
//console.log(my_JSON_object[0]);
for (i=0;i<my_JSON_object.length;i++){
console.log(my_JSON_object[i]);
// document.getElementById("conteudo").innerHTML += "<li>" + my_JSON_object[i].sportname + "</li>";
var node = document.createElement("LI");
var textnode = document.createTextNode(my_JSON_object[i].sportname);
node.appendChild(textnode);
document.getElementById("conteudo").appendChild(node);
}
}
}
}
</script>
</body>
</html>