-
Notifications
You must be signed in to change notification settings - Fork 0
/
View.js
58 lines (52 loc) · 1.54 KB
/
View.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
if (typeof HealthCare === 'undefined')
HealthCare = {};
window.onload = init;
function init()
{
HealthCare.view.display();
}
HealthCare.view = {
display: function () {
var promise = HealthCare.controller.createAjaxObject();
promise.then(function(data) {
HealthCare.model = data;
viewData();
},
function(error)
{
console.log(error);
}
);
//setTimeout(viewData, 4000);
}
}
function viewData()
{
console.log(HealthCare.model);
var table = document.createElement('Table');
table.setAttribute("border", "2");
jobj=JSON.parse(HealthCare.model);
for(pos in jobj)
{
tr = document.createElement('tr');
td = document.createElement('td');
node = document.createTextNode(jobj[pos].id);
td.appendChild(node);
tr.appendChild(td);
td = document.createElement('td');
node = document.createTextNode(jobj[pos].username);
td.appendChild(node);
tr.appendChild(td);
td = document.createElement('td');
node = document.createTextNode(jobj[pos].address.city);
td.appendChild(node);
tr.appendChild(td);
td = document.createElement('td');
node = document.createTextNode(jobj[pos].address.zipcode);
td.appendChild(node);
tr.appendChild(td);
table.appendChild(tr);
}
var ref = document.getElementById('response');
ref.appendChild(table);
}