How to pass Authorization header with parameters in DataTable Ajax call
How to pass Authorization header with parameters in DataTable Ajax call
shweta24july
Posts: 1Questions: 1Answers: 0
I need to pass Authorization header token with ajax call below is code I am trying
sServerMethod: 'post',
"ajax": {
"url": 'http://localhost:111111/api/Support/GetAllTickets',
"dataType": 'json',
"type": 'Post',
"beforeSend": function (xhr) {
xhr.setRequestHeader('Authorization',
"Bearer " + sessionStorage.getItem('accesstoken'));
},
"fnServerParams": function (aoData) {
aoData.push({ "name": "sdisp", "value": selectedval });
aoData.push({ "name": "ticketbystatus", "value": typeofticket });
},
},
this is reaching to web API but parameters is not passed.
Please help
This discussion has been closed.
Answers
Hi @shweta24july ,
This thread here may help - it's discussing the same issue. Also, this may be useful,
Cheers,
Colin
There's 'headers' property:
There is no
fnServerParams
option in theajax
object. You wantajax.data
.Allan