layui设置ajax请求头允许跨域携带cookie

有时候后台需要从请求中获取cookie,需要前端进行设置,否则后台无法直接获取,layui的table请求没有暴露此接口,进行ajax全局配置即可解决。

1  //ajax全局配置跨域
2     $.ajaxSetup({
3         ...
4         crossDomain: true,
5         xhrFields: {
6             withCredentials: true
7         }
8     });

 

posted @ 2021-03-09 14:59  阳仔呦  阅读(993)  评论(0)    收藏  举报