1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试CORS</title>
    <script src="libs/jquery.min.js"></script>
    <script type="text/javascript">
    var token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNTE1NjYzNjgzLCJleHAiOjE1MTU3NTAwODN9.GlFPablO3N7Eu8tZTur5c4X_J9P-KBHN7VMpzNztLxAjOH5D0iAx1TZsYKDF4Ich79170uqSnIgCNl4MRHDLAA";
    token = "d7542e71b55527032581611bc399b619";
    // cd88a2a7f2342fbef79d424fd482f0b7
 
    $.ajaxSetup({
        headers: {
            "token": token
        }
    });
 
    var url = "http://192.168.0.130:8081/api/login";
    //url = "http://192.168.0.130:8081/api/login?username=admin&password=admin";
    url = "http://192.168.0.130:8081/api/test";
 
    // url = "http://192.168.0.130:8081/org/user/info?_=1515667870022";
 
    // url = "http://192.168.0.130:8081/api/test?token=" + token;
    $(function(){
        $("#cors").click(function(){
            /**
            $.ajax({
                url: url,
                // headers: {
                //     "token": token
                // },
                success: function(data){
                    alert(JSON.stringify(data));
                }
            }); //*/
 
            $.getJSON(url, function(data){
                alert(JSON.stringify(data));
            });
        });
 
    });
    </script>
</head>
<body>
    <input type="button" id="cors" value="CORS跨域测试">
</body>
</html>