-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
43 lines (39 loc) · 1.1 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
<!doctype html>
<html class="no-js" lang="zh" xmlns:https="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>JinAjax</title>
</head>
<body>
<h1 style="text-align:center">请打开控制台查看请求</h1>
<script src="./plugin.js"></script>
<script>
var obj = {
methods: 'GET',
url: './test.json', //普通请求测试URL
// url: 'http://www.runoob.com/try/ajax/jsonp.php', //JSONP测试URL
header: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
data: {
url: '123'
},
timeout: 5000,
async: true,
type: 'json',
jsonp: 'jsoncallback', //JSONP 约定的回调方法名
success: function (res) {
console.log(res)
},
error: function (e) {
console.error(e)
},
before: function () {
console.log('发起请求之前先执行before方法')
}
}
var ajax = new JinAjax(obj)
</script>
</body>
</html>