ajax请求发送cookie

javascript
$.ajax({
url: 'https://example.com/api/data',
method: 'GET',
xhrFields: {
withCredentials: true // 允许跨域请求时发送 cookies
},
success: function(response) {
console.log(response);
},
error: function(error) {
console.error(error);
}
});

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: