12-设置请求头参数的ajax请求

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/rulaixiong/article/details/87605233
demo如下:
<html>
<head>
    <meta charset="utf-8">
    <title>request</title>
</head>
<body>
<button onclick="btn()">按钮</button>
</body>
<script src="jquery-3.3.1.min.js"></script>
<script>
function btn() {
    var token = "6oFm0_4wp65v55CFuc4er41_qaZ6cYOv_1550458274";
    $.ajax({
        type:"GET",
        contentType: "application/json",
        url:"http://api.luckymoney.com/admin/members",
        beforeSend:function (request) {
            request.setRequestHeader("token", token);
        },
        success:function (res) {
            console.log(res);
        }
    });
}
</script>
</html>
展开阅读全文

没有更多推荐了,返回首页