I am requesting cross origin domain and adding custom headers. But header is not getting in server side.
Code:
$.ajax({
type: "GET",
crossDomain: true,
beforeSend: function (request) {
request.setRequestHeader("Authorization", "Bearer " +($("#accesstoken").val()));
},
url: myJSonServer + encodeURI(operation),
dataType: 'jsonp',
cache: false,
success: callback,
error: function (jqXhr, textStatus, errorThrown) { alert(textStatus + ": " + errorThrown); }
});
In server side added:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: *
Access-Control-Request-Method: *