-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06.html
40 lines (36 loc) · 904 Bytes
/
06.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
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<title>FETCH EXAMPLE</title>
<script>
function print(e, m) {
document.getElementById(e).innerHTML += `<div>${m}</div>`;
}
{{range $c, $v := .Commands}}
async function {{$c}}() {
let response = await fetch("{{$c}}");
if (response.ok) {
let body = await response.text();
print("event_log", body);
} else {
print("event_log", `Request Failed: ${response.status}`);
}
}
{{end}}
</script>
</head>
<body>
<h1>FETCH EXAMPLE</h1>
<h2>Known Asynchronous Actions</h2>
<div>
{{range $c, $v := .Commands}}
<span>
<button type="button" onclick="{{$c}}();">{{$c}}</button>
</span>
{{end}}
</div>
<h2>Server Output</h2>
<div id='event_log'></div>
</body>
</html>