Setting header in AJAX request

Setting header in AJAX request

tacman1123tacman1123 Posts: 198Questions: 46Answers: 1

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

Answers

This discussion has been closed.