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);
}
});