我的代码:
$.ajax({
origin: "*",
url: 'http://SP/api/test',
type: 'get',
dataType: 'jsonp',
crossDomain: true,
beforeSend: function (xhr) {
xhr.setRequestHeader("API_KEY", "XX");
xhr.setRequestHeader("Authorization", "XX";
},
success: function (data) {
});
},
error: function (y) {
}
});
请求标题:
GET http://SP/api/testcallback=jQuery22406877213234276709_1489930192633&_=1489930192634 HTTP/1.1Host:http://SP/
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Accept: */*
Referer: http://SP/api/test
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
我相信我应该添加 Access-Control-Allow-Headers ,但我不知道在哪里添加。