-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
43 lines (41 loc) · 1.42 KB
/
Copy pathindex.html
File metadata and controls
43 lines (41 loc) · 1.42 KB
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 lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Users</h1>
<div id="mediaReleases"></div>
</div>
<script>
var xmlhttp = new XMLHttpRequest();
var url = "http://jsonplaceholder.typicode.com/users";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArr = JSON.parse(xmlhttp.responseText);
myFunction(myArr);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(arr) {
var out = "<table class='table'><tr><th>Name</th><th>User Name</th><th>Email</th></tr>";
var i;
for(i = 0; i < arr.length; i++) {
out += "<tr><td>" + arr[i].name + "</td><td>" +
arr[i].username + "</td><td>" + arr[i].email + "</td></tr>";
}
out += "</table>";
document.getElementById("mediaReleases").innerHTML = out;
}
</script>
</body>
</html>