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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
| <!DOCTYPE html>
| <html lang="zh-cn">
| <head>
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
| <title>智能粮库管理系统</title>
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
| <script src="../../static/lib/jquery/jquery-3.4.1.min.js"></script>
| </head>
| <body>
|
| <div style="margin: 20px; text-align: center;">
|
| <div>
| <span>请输入GET请求URL</span><input id="input_url"/>
| <span>格式:http://ip:port/path</span>
| </div>
|
| <div style="height: 10px;"></div>
|
| <button onclick="testClick()">普通GET请求</button>
| <button onclick="testJsonp()">JSONP请求</button>
| </div>
|
|
| <script>
|
| //测试普通请求
| function testClick() {
|
| let url = $("#input_url").val();
| if (!url) {
| alert("请输入URL");
| return;
| }
|
| $.ajax({
| type: "GET",
| async: true,
| url: url,
| data: {},
| dataType: "json",
| success: function (result) {
| alert("success" + result);
| },
| error: function (result) {
| alert("error" + result);
| }
| });
| }
|
| //测试JSONP
| function testJsonp() {
| let url = $("#input_url").val();
| if (!url) {
| alert("请输入URL");
| return;
| }
|
| $.ajax({
| type: "GET",
| async: true,
| url: url,
| data: {},
| dataType: "jsonp",
| jsonp: "callback",
| jsonpCallback: "jsonpCallback",
| success: function (result) {
| alert("success" + result);
| },
| error: function (result) {
| alert("error" + result);
| }
| });
| }
|
| </script>
|
| </body>
| </html>
|
|