thinkphp6 header token头发送和接受
<form action="{:url('index2')}">
<input type="text" name="user" id="user">
<input type="button" id="abc" value="tijiao">
</form>
<script>
$("#abc").click(function(){
let admintoken=6666; //可有服务端获取或客户端缓存获取
$.ajax({
headers: {
"zzzyk": yizuotu
},
url:"{:url('/test')}",
data: {user:$("#user").val()},
success:function (res) {
console.log(res);
},
error:function(){
}
})
})
</script>
public function test()
{
print_r(Request::header('ZZZYK'));
//这个也可以获取
// header("ZZZYK:{$token}");可以服务端发送
echo $_SERVER['HTTP_ZZZYK'];
}
显示推荐内容