-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
47 lines (46 loc) · 1.35 KB
/
index.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
41
42
43
44
45
46
47
<!-- Session 测试页面 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>登录</title>
</head>
<body>
<div>
<label for="user">username:</label>
<input type="text" name="user" id="user" />
</div>
<div>
<label for="password">password:</label>
<input type="text" name="password" id="password" />
</div>
<button type="button" id="login">login</button>
<h1 id="data"></h1>
<script>
const login = document.getElementById("login");
login.addEventListener("click", function(e) {
const user = document.getElementById("user").value;
const password = document.getElementById("password").value;
if (!user || !password) {
return;
}
const req = fetch("http://localhost:3000/login", {
method: "post",
body: `user=${user}&password=${password}`,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
});
req
// .then(stream => {
// staream.text();
// })
.then(res => {
document.getElementById("data").innerText = res;
});
});
</script>
</body>
</html>