-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
37 lines (37 loc) · 1.18 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<script>
$(function () {
const url = 'http://jsonplaceholder.typicode.com/users';
const settings = {
url,
type: 'post',
// 测试数据
data: JSON.stringify({
user: {
username: 'scott',
password: 'tiger',
}
}),
success: function (response) {
console.log(response);
}
}
$('button#payload').on('click', () => {
$.ajax(Object.assign(settings, {contentType: 'application/json'}))
})
$('button#form-data').on('click', () => {ad
$.ajax(Object.assign(settings, {contentType: 'application/x-www-form-urlencoded'}))
})
})
</script>
</head>
<body>
<button id="payload">以payload的方式发送请求</button>
<button id="form-data">以form-data的方式发送请求</button>
</body>
</html>