天天看点

模拟跨域请求前台页面代码模拟跨域请求前台页面代码

模拟跨域请求前台页面代码

被调用方后台代码编写

调用方前台代码编写

引入前台Jasmine测试框架

1、创建Spring Boot工程

模拟跨域请求前台页面代码模拟跨域请求前台页面代码

创建Spring Boot工程

模拟跨域请求前台页面代码模拟跨域请求前台页面代码

创建Spring Boot工程

模拟跨域请求前台页面代码模拟跨域请求前台页面代码

Web-Web提供Web服务

2、创建HTML页面

模拟跨域请求前台页面代码模拟跨域请求前台页面代码

index.html代码

<!DOCTYPE html>

<html >

<head>

    <meta charset="UTF-8">

    <title>ajax-cross-doman</title>

    <!-- minified -->

    <script src="jquery-1.11.3.min.js"></script>

</head>

<body>

    <a href="#" target="_blank" rel="external nofollow" οnclick="get1()">发生get请求</a>

    <script type="text/javascript">

        function get1(){

            $.getJSON("http://localhost:8081/test/get1").then(

                function(result){

                    console.log(result)

                }

            )

        }

    </script>

</body>

</html>

3、下载jQuery库

模拟跨域请求前台页面代码模拟跨域请求前台页面代码

继续阅读