How to change Ajax Request Headers in Datatables

How to change Ajax Request Headers in Datatables

RezalfaRezalfa Posts: 1Questions: 1Answers: 0

Hi.
I use Datatables for my project. i have problem about header when i send a request from datatables to my controller in mvc.
the X-Requested-With is missing in header and the if case " Request.IsAjax() " returns false!!!
how can i fix that?
Thanks.

Answers

  • allanallan Posts: 62,994Questions: 1Answers: 10,368 Site admin

    The ajax option basically just extends the jQuery ajax object, so anything you can do with jQuery's Ajax you can do in DataTables - e.g.:

    $(...).DataTable( {
      ajax: {
        url: ...,
        headers: {
          'X-Requested-With': ...
        }
      }
    } );
    

    Allan

This discussion has been closed.