-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path07.html
37 lines (33 loc) · 836 Bytes
/
07.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
<!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}}() {
fetch("{{$c}}")
.then(response => response.text())
.then(text => print("event_log", text))
.catch(e => print("event_log", `Request Failed: ${e}`));
}
{{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>