-
Notifications
You must be signed in to change notification settings - Fork 0
/
Retrieve.html
48 lines (40 loc) · 1.29 KB
/
Retrieve.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
46
47
48
<!DOCTYPE html>
<html>
<head>
<title>Account Information</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
</head>
<body>
<script>
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://129.213.63.76:30080/list/");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onload = function() {
if (this.readyState == 4 && this.status==201)
{
document.write("<h2>List of all users</h2>");
var dict = JSON.parse(this.responseText)
if(dict.length==0){
document.write("<h3>No users found.</h3>")
}else{
document.write("<ul>")
for (var user of dict)
{
document.write("<li>")
document.write("<h3>Name : "+user.name+"</h3>");
document.write("<h3>Email : "+user.email+"</h3>");
document.write("</li>")
}
document.write("</ul>")
}
}
else if(this.readyState == 4 && this.status==400)
{
alert(this.responseText.replace(/['"]+/g, ''));
}
}
</script>
</body>
</html>