0

I am trying to add custom header with ajax call but i can't do this.

Here is ajax call

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

But i am getting this error on console.

 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.

It pass all the header in Access-Control-Request-Headers:authorization,content-type,securehash

enter image description here

Zaheerabbas
  • 1,119
  • 20
  • 46
  • Possible duplicate of [How can I add a custom HTTP header to ajax request with js or jQuery?](http://stackoverflow.com/questions/7686827/how-can-i-add-a-custom-http-header-to-ajax-request-with-js-or-jquery) – ganesh deshmukh May 04 '17 at 18:56
  • have tried it with that but no luck – Zaheerabbas May 05 '17 at 00:27

0 Answers0