-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
48 lines (47 loc) · 1.37 KB
/
index.html
File metadata and controls
48 lines (47 loc) · 1.37 KB
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
48
<!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>Document</title>
<link rel="stylesheet" href="css.css">
</head>
<body>
<script type="module">
import * as $ from "./node_modules/jquery/dist/jquery.js";
</script>
<button id="get">GET请求资源</button>
<br>
<label for=""><input type="text" id="name"> 名字</label>
<br>
<label for=""><input type="text" id="hobby"> hobby</label>
<br>
<button id="post">POST请求资源</button>
<script>
const get = document.getElementById("get")
get.onclick=()=>{
$.ajax({
url:"http://127.0.0.1:6060/default",
type:"GET"
})
.then( res=>{
console.log(res)
} )
}
const post = document.getElementById("post")
post.onclick=()=>{
let name = document.getElementById("name").value
let hobby = document.getElementById("hobby").value
$.ajax({
url:"http://127.0.0.1:6060/post",
type:"POST",
data:{name,hobby}
})
.then( res=>{
console.log(res)
} )
}
</script>
</body>
</html>