Ajax跨域请求,并携带cookie
1. 需此刻处事端允许跨域,允许携带cookie
因处事端脚本语言差别,,自行搜索设置
2. 前端Ajax跨域请求代码
$.ajax({
type: "POST",
url: "http://127.0.0.1:8000/api/login",
data: JSON.stringify({‘num‘: 1}),
dataType: ‘json‘,
xhrFields: {
withCredentials: true //允许跨域带Cookie
},
success: function(data) {
console.log(data)
}
})
前端Jquery-Ajax跨域请求,并携带cookie
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/30154.html