Datatables does nothing with the json it requested
I am using Yajra's Datatables to populate my table and I did everything by the book. The controller is set up correctly, the routes are good (if I enter the route designated to the controller function which creates the Database, I can see the desired json in the desired format:
{"draw":0,
"recordsTotal":44,
"recordsFiltered":44,
"data":[{
"agency":"agency",
"number":"20966512",
"name":"Name John",
"value":"28.22",
}]
}
This is the .js code that I use to create my datatable:
$(document).ready(function() {
$('#tbl').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route("datatable") !!}',
columns: [
{data: 'agency', name: 'agency'},
{data: 'number', name: 'number'},
{data: 'name', name: 'name'},
{data: 'value', name: 'value'},
]
});
});
I am getting an error stating:
DataTables warning: table id=tbl - Ajax error. For more information about this error, please see http://datatables.net/tn/7
When I look in the console I get the following error:
{
"message": "",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
"file": "/home/vagrant/Projects/Uniqa-ACB/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
"line": 179,
"trace": etc...
}
Laravel 5.8, PHP 7.3, Yajra DT: 6, datatables.net: 1.10
Thank you in advance, if you need any more code I wil gladly input it.
NotFoundHttpException
- something's not found on your backend. Show you controller method or something where do you process data. – TarasovychNotFoundHttpException
means Laravel failed to match any route for a request. He needs to look at his routes file and URL that was requested via ajax call. – d3jn