-
Notifications
You must be signed in to change notification settings - Fork 0
/
JSONExample.html
28 lines (25 loc) · 931 Bytes
/
JSONExample.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="initial-scale=1, width=device-width">
<title>shows</title>
</head>
<body>
<input autocomplete="off" autofocus placeholder ="Query" type="search">
<ul></ul>
#JSON script
<script>
let input = document.querySelector('input');
input.addEventListener('input', async function() {
let response = await fetch('/search?q=' + input.value);
let shows = await response.json();
for html = '';
for (let id in shows) {
let title = shows[id].title.replace('<', '<').replace('&', '&');
html += '<li>' + title '</li>';
}
document.querySelector('ul').innerHTML = html;
});
</script>
</body>
</html>