I've a problem with an exception from DataTable.
In the controller of the API, I'm using [Authorize]. Without this, it works.
By selecting an item start the ajax call...
var urlCompleto = ".....";
$.ajax({
'url': urlCompleto,
'method': "GET",
'contentType': 'application/json'
}).done(function (data) {
...
})
.fail(function () {
....
})
});
So appare an allert: DataTables warning: table id=querytable - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1. And the status of the request is 403.
How do I make it work even if authorized?
I tried to put "RequestVerificationToken" in the headers of the ajax call, but nothing...
I tried to AddAntiForgeryToken and pass it like data in the ajax call, but nothing....
How can I solve this problem?
Thanks in advance.
EDIT
If I take:
var token = $('input[name="__RequestVerificationToken"]').val();
and pass it like "data" in an ajax call of type:"post" I've no error. So how can I "pass" this token in an ajax call of type:"get"?