-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
56 lines (45 loc) · 1.19 KB
/
test.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
var out = document.getElementById("out");
function addToHistory(item) {
if (item == 'apples') {
loadApples();
} else if (item == 'pears') {
loadPears();
} else if (item == 'oranges') {
loadOranges();
} else {
out.innerHTML = item;
}
}
function loadApples() {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
out.innerHTML = xmlHttp.responseText;
history_update("loadApples()");
}
}
xmlHttp.open("GET", "php/loadItem.php?item=apples");
xmlHttp.send();
}
function loadPears() {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
out.innerHTML = xmlHttp.responseText;
history_update("loadPears()");
}
}
xmlHttp.open("GET", "php/loadItem.php?item=pears");
xmlHttp.send();
}
function loadOranges() {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
out.innerHTML = xmlHttp.responseText;
history_update("loadOranges()");
}
}
xmlHttp.open("GET", "php/loadItem.php?item=oranges");
xmlHttp.send();
}