ajax跨域,cookie,session失效的问题解决办法

前端之家收集整理的这篇文章主要介绍了ajax跨域,cookie,session失效的问题解决办法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

后台设置:

response.setHeader("Access-Control-Allow-Credentials","true");
response.addHeader("Access-Control-Allow-Origin",request.getHeader("Origin"));
response.addHeader("Access-Control-Allow-Methods","POST");
response.addHeader("Access-Control-Allow-Headers","x-requested-with,content-type");


ajax写法

$.ajax({
type : "POST",
url : 'https:/
/xxxx:18080/app/company/queryList?currentPage=1&pageSize=10',
dataType : "JSON",
data : "",
async: false,
xhrFields: {withCredentials: true}, success : function(data){ console.log("2="+ data.obj); } });

原文链接:https://www.f2er.com/ajax/160998.html

猜你在找的Ajax相关文章