what does your laravel log file say?
DataTables warning: table id=student_table - Ajax error. http://datatables.net/tn/7 with Yajra Laravel
I just used Yajra (datatable "yajra/laravel-datatables": "^1.0" ) on laravel (5.4.16), PHP version 7.1 .
I got this error while loading :
DataTables warning: table id=student_table - Ajax error. For more information about this error, please see http://datatables.net/tn/7
and on inspect:
jquery.js:8526 GET http://127.0.0.1:8000/leads/testing?draw=2&columns%5B0%5D%5 500 (Internal Server Error)
this is my app.php:
Yajra\DataTables\DataTablesServiceProvider::class,
AND
'DataTables' => Yajra\DataTables\Facades\DataTables::class
and I tried to make the ' Y ' small letter but still have the same error.
My controller :
use DataTables;
class LeadsController extends Controller
{
public function gettesting()
{
return view('testing');
}
public function testing()
{
$students = Meeting::select('name', 'details');
return DataTables::of($students)->make(true);
}
}
my route is as follows:
Route::get('testing', 'LeadsController@gettesting');
Route::get('leads/testing', 'LeadsController@testing')->name('leads.testing');
My view 'testing' :
<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
</head>
<body>
<div class="container">
<br/>
<br/>
<div align="right">
<button type="button" name="add" id="add_data" class="btn btn-success btn-sm">Add</button>
</div>
<br/>
<table id="student_table" class="table table-bordered" style="width:100%">
<thead>
<tr>
<th>name</th>
<th>details</th>
</tr>
</thead>
</table>
</div>
<script>
$(document).ready(function () {
$('#student_table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "{{ url('leads/testing') }}",
"method": "GET",
"columns": [
{"data": "name"},
{"data": "details"}
]
});
});
</script>
</body>
</html>
Please help me to solve it
@lyiub Delete this file and run
php artisan vendor:publish --provider="Yajra\DataTables\DataTablesServiceProvider"
Then
composer dump-autoload
Please or to participate in this conversation.