I am trying to send an API key via headers, so not in the data associated to a GET/POST request. I have tried several options that you can see uncommented in the code below or in this jsfiddle
I am not sure if it is really sending the header, that is, 'my_api_key' parameter/value, as I cannot see them in console inspector (and I have seen other applications where these values appeared somewhere in the console request).
$.ajax({
url: "https://api.github.com/users/jeresig",
type: "GET",
/*
headers: { 'my_api_key': 'xxxx' },
*/
beforeSend: function(request) {
request.setRequestHeader("my_api_key", 'xxxx');
},
/*
headers: {
'Accept': 'application/json',
'my_api_key':"xxxx"
},
*/
dataType: "jsonp"
//jsonpCallback: "logResults"
});