I have a simple Laravel app with a single data table that processes data serverside and serves it to the page. It uses a package, yajra/laravel-datatables. This works fine when testing locally (php artisan serve), but when the app is hosted I get an error on page load:
DataTables warning: table id=program-table - Ajax error. For more information >about this error, please see http://datatables.net/tn/7
and my request returns a 404 in the dev tools. I assume this issue sprouts somewhere in the routing, as the server is hosted with IIS and has several rewrite rules- although disabling them hasn't had any effect.
My laravel route looks like:
Route::get('/serverSide', [
'as' => 'serverSide',
'uses' => function () {
$model = \App\Degree::query();
return DataTables::eloquent($model)->toJson();
}
]);
And my DataTable setup is:
$('#program-table').DataTable({
processing: true,
serverSide: true,
ajax: "{{ route('serverSide') }}",
columns: [
{
"className": 'details-control',
"orderable": false,
"data": null,
"width": '5%',
"searchable": false,
"defaultContent": ''
},
{ data: 'cip', width: '10%'},
{ data: 'cip_title' },
{ data: 'item_name' },
{ data: 'degree_name_list' },
{ data: 't_state_code_list', width: '7%' },
{ data: 'p_state_code_list', width: '7%' },
{ data: 's_state_code_list', width: '7%' }
],
pageLength: 25,
searching: true,
paging: true,
"order": [[ 1, "asc" ]]
});
If anyone has any experience with a similar issue or solution I would be happy to know! Thank you very much