首页> 实战笔录 >PHP开发笔记 >ThinkPHP ThinkPHP
Tp6 $request->isAjax()不能验证axios提交的请求
作者:小萝卜 2024-04-15 【 TP6 Vue3 】 浏览 1352
简介Tp6 $request->isAjax()不能验证axios提交的请求,需要在请求头部header中添加对应参数XMLHttpRequest
Tp6 $request->isAjax()不能验证axios提交的请求
原因:axios 请求头中没有带 X-Requested-With 这个参数。
解决办法:
给请求头添加 X-Requested-With 这个参数,参数值为 XMLHttpRequest
// 以 axios 为例
this.$axios.get('http://yourdomain.com/api/getMenus',
{
headers: {'X-Requested-With': 'XMLHttpRequest'}
}).then((res)=>{
// console.log(res.data);
})
很赞哦! (0)
相关文章
- tp5/tp6新增app版本跟新接口
- TP6阿里云OSS上传报SSL certificate problem:unable to get local issuer certificate
- tp6表单验证提交之后报错Call to a member function set() on null
- TP5.0 给图片加文字水印怎么控制文字的透明度
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Attr_id' in 'where clause'
- phpQuery介绍及简单的使用
- TP5.1 钩子与行为应用
- TP6配置安装多应用模式后报错HTTP ERROR 500
- TP6/ThinPHP 修改错误级别
- tp5.0使用think-queue+redis实现消息队列简易教程
