-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
31 lines (29 loc) · 837 Bytes
/
demo.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
<!DOCTYPE html>
<html>
<head>
<title>Closure demo</title>
</head>
<body>
<h2>Data handling happens below</h2>
<button id="btn">Clicky</button>
<h3 id="insertion"></h3>
<script type="text/javascript">
function fetchContent() {
var req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (req.readyState === 4) {
if (req.status === 200) {
// Do something, the request is ready
document.getElementById('insertion').innerHTML = req.responseText;
} else {
alert("Request failure");
}
}
};
req.open('GET', '/rest/foobar', true);
req.send(null);
}
document.getElementById('btn').onclick = fetchContent;
</script>
</body>
</html>