Adding A HTTP Header to the Ajax request.
Adding A HTTP Header to the Ajax request.
Hey I am struggling to try and add a HTTP header to the request when I have an ajax datatable.
I am trying to add a header called Apitoken to my request. In jquery I have been doing:
headers: { 'Apitoken': apiToken },
My table is defined as follows:
var table = $('#dataTables-site-vehicle').DataTable( {
"processing": false,
"serverSide": false,
"ajax":{
url: baseApiUrl +"site/" + siteId + '/vehicles',
type: "GET",
});
However I am struggling to find any reference to changing the request made. I am using datatables 1.10 and was unable to find anything. Anyone know how to do this or at least know where I can find the docs to assist.
Many thanks for your time. Im sure I am just missing some school boy errors.
Matthew
Answers
should do it. The
ajax
option is just basically pass through to jQuery's$.ajax
.Allan