Laravel csrf token mismatch when using ajax with datatable

Hello, I am trying to use datatable in my laravel project. But I am getting this CSRF Token Mismatch error how do I solve that?

$(document).ready(function () {
    $('#my-table').DataTable({
        processing: true,
        serverSide: true,
        serverMethod: 'post',
        ajax: 'ajax-url', 
        columns: [ 
            { data: 'name' },
            { data: 'position' },
            { data: 'office' }
        ],
    });
});

I know I can send CSRF Token to laravel server like below.

"data": {
    "_token": "{{ csrf_token() }}"
},

But this is not working with datatable. Is there any way I can send additional parameters with the ajax request?

You can simply send the CSRF Token with the header request. All you have to do is change the ajax parameter.

ajax : {
    url  : '{{ route('route.name') }}',
    beforeSend : function(xhr) {
      xhr.setRequestHeader('X-CSRF-TOKEN', '{{ csrf_token() }}');
    }
},