0
votes

I am receiving error,

"DataTables warning: table id=table-timsheet - Ajax error. For more information about this error, please see http://datatables.net/tn/7"

when accessing the page which contain data tables.

Its a Laravel5.8 application running on php7.2. The same files I have uploaded in other servers and they are loading fine.

When inspecting the code, "Console" tab shows the below given error.

"403 (Forbidden)"

I have cross checked the file permissions but they seems to be okay. (755 for folders and 644 for files)

If I am commenting the code below, then the error disappears but the data wont load.

The data should display in the data table as fetching from database.

1
If I am commenting the code below, then the error disappears but the data wont load. <script> $(function() { let tableTimesheet = $('#roster-table'); let dataTableTimesheet = tableTimesheet.DataTable({ ajax: { data: function (d) { d.shift_date = '10'; } } }); }); </script> - Sumith

1 Answers

0
votes

What is the URL you are providing to the DataTables Ajax call?

If you are using a POST method, you need to incorporate a CSRF token. If you have Jquery enabled, you can use this to initialize. Please note this also requires adding the CSRF token to a block in the head.

      $.ajaxSetup({
            headers: {
               'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
      });

Altenatively, you can include it as a data parameter in the specified AJAX call:

data: {'csrf': {{crsf_token}} }