i want to use yajra datatable in my laravel 5.6 app i have install the yajra package using this (composer require yajra/laravel-datatables-oracle) and include the js in my layout files when i run the app with php artisan serve it show this error (DataTables warning: table id=datatableclass - Invalid JSON response. ) any one can solve this thanks in advance.
config/app
'providers' => [
....
Yajra\Datatables\DatatablesServiceProvider::class,
],
'aliases' => [
....
'Datatables' => 'Yajra\Datatables\Facades\Datatables',
]
this is ajax call
$(document).ready(function() {
$('#datatableclass').DataTable({
processing: true,
serverSide: true,
ajax: '{{ route('class.getclasses') }}',
columns: [
{data: 'id', name: 'id'},
{data: 'class_name', name: 'class_name'},
]
});
});
this is my routes
Route::resource('/class','ClassController');
Route::get('/class/get-classes', 'ClassController@getClass')->name('class.getclasses');
this is my controller
use Illuminate\Http\Request;
use App\Http\Requests\SchoolClassRequest;
use App\SchoolClass;
use Datatables;
public function index()
{
return view('school_admin.entry.class');
}
public function getClass()
{
$school = auth()->user()->school()->first();
$classes = SchoolClass::where('school_id', $school->id)->get();
return DataTables::of($classes)->make(true);
}
and this is my table in views
<table class="table" id="datatableclass">
<thead>
<tr>
<th data-field="ID">Id</th>
<th data-field="Class" data-sortable="true">Class Name</th>
</tr>
</thead>
</table>