Jquery AJAX triggers preflight OPTIONS request only when I include headers
I am trying to send a request to the Web API hosted in another domain. In fiddler when I intercept the calls it makes a OPTIONS request only when I add headers. If I remove the headers option from the ajax call, it sends a GET request but there is no response in either case. Can anyone please explain me why the calls are intercepted differently when I add a header option.
$.ajax({
url: request.url,
method: 'GET',
//dataType: 'json',
//data: request.body,
//contentType: 'text/plain',
headers:{"a":"b"},
beforeSend: function () {
},
success: function (data, textStatus, request) {
},
error: function (e) {
},
complete: function () {
}
});