Setting header in AJAX request
Setting header in AJAX request

I keep searching and hacking away at this, but can't figure out how to send headers to the AJAX request.
ajax: {
url: url,
headers: {
"Accept" : "application/ld+json",
"Content-Type": "text/json; charset=utf-8"
},
beforeSend: function (request) {
console.error(request);
request.setRequestHeader("Accept", 'application/ld+json');
},
The AJAX call is made to the URL, but the headers aren't correct, and beforeSend isn't called. (not show: dataFilter, which also doesn't seem to be called). The ajax object is passed on directly to jquery, right? The only exception is to not override the success call, which datatable uses internally, right?
Thanks,
Tac
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Your code snippet seems to work here:
http://live.datatables.net/vunugita/1/edit
Do you happen to have a second
ajax
option configured?Can you post a link to your page or a test case replicating the issue so we can help debug?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thanks, I must have something configured incorrect, because indeed that does work when I try it in a different script.