第一种
$.ajax({
url: 'www.xoxxoo.com',
type: 'post',
data: '',
// 默认情况下,标准的跨域请求是不会发送cookie的
xhrFields: {
withCredentials: true
},
success: (rs) {
}
})
第二种 ,因为有时候第一种情况cookie也是带不过去。就用第二种方式
$.ajax({
url: 'www.xoxxoo.com',
type: 'post',
data: '',
// 默认情况下,标准的跨域请求是不会发送cookie的
beforeSend: function (xhr) {
xhr.withCredentials = true
},
success: (rs) {
}
})