很简单只需要添加:
xhrFields: {
withCredentials: true,
}
完整示例:
$.ajax({
type: "POST",
url: "http://127.0.0.1:8000/api/test",
data: JSON.stringify({'user': 123,'pass':'123456'}),
dataType: 'json',
xhrFields: {
withCredentials: true //允许跨域带 Cookie
},
success: function(data) {
console.log(data)
}
})
话尾
很久很久不更新博客了,上回更新还是 8 月份,不更新的原因很多...哎...
以后也基本不会怎么更新了...随缘吧...
马上元旦了,预祝大家元旦快乐吧!







