(1)请求web

 用来测试api的例子

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <button>test</button>

    <!--需要本地文件-->
    <script src="jquery-3.3.1.js"></script>
    <!--需要联网-->
    <!--<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>-->

    <script>
        $(function () {
            $("button").click(function () {
                $.post("http://localhost:8888/api/user",
                    {
                        User: "xxx",
                        PassWord: "xxx"
                    },
                    function (data, status) {
                        alert("数据: \n" + data + "\n状态: " + status);
                    });
            });
        });
    </script>
</body>
</html>

 运行后点击按钮test

猜你喜欢

转载自www.cnblogs.com/buchizaodian/p/10118405.html
今日推荐