我正在尝试使用ajax调用添加自定义标头,但我不能这样做。
这是ajax调用
$j(document).ready(function(){
$j.ajax({
method: 'POST',
url: 'https://mysecoure.com/test/v1/api/getWebSessionKey',
headers: {'Content-Type': 'application/json','Authorization' : 'Bearer 69bb9df-b7e5-b6583392fce8','SecureHash':'d1eb5d981cc036764979fc26c837ecc255cfbad208b583a'},
data: {
'MERCH_ORDER_ID' : 'ORDER12234213',
'TXN_AMOUNT' : '12.00',
'RET_URL_SUCC' : 'http://localhost:8580/mysecure/return.jsp',
'SELLER_NAME' : 'test'
}
})
.done(function( msg ) {
console.log(msg);
});
});
但我在控制台上收到此错误。
XMLHttpRequest cannot load https://mysecoure.com/test/v1/api/getWebSessionKey. Request header field SecureHash is not allowed by Access-Control-Allow-Headers in preflight response.
它传递Access-Control-Request-Headers:authorization,content-type,securehash