[英]DataTables warning: table id=DataTables_Table_0 - Ajax error
I used Datatables in laravel and getting below warning message: 我在laravel中使用了数据表,并收到以下警告消息:
DataTables warning: table id=DataTables_Table_0 - Ajax error. DataTables警告:表格ID = DataTables_Table_0-Ajax错误。 For more information about this error, please see http://datatables.net/tn/7 有关此错误的更多信息,请参见http://datatables.net/tn/7
I can't get the JSON data from my table in database 我无法从数据库中的表中获取JSON数据
here my controller 这是我的控制器
public function data()
{
// return Datatables::of(Employee::select("*"))->make(true);
$users = Employee::select(['id','employee_name','gender', 'join_date', 'identity_no', 'birthdate', 'idaddress']);
return Datatables::of($users)->make();
}
Route 路线
Route::any("data", "EmployeeController@data");
Model 模型
public function attributeLabels()
{
return [
"id" => "id",
"nik" => "Nik",
"employee_name" => "Nama Pegawai",
"gender" => "Jenis kelamin",
"join_date" => "Tgl bergabung",
"identity_no" => "No identitas",
"birthdate" => "Tgl Lahir",
"idaddress" => "Alamat",
];
}
Table 表
<table class="table table-bordered" datatable="{{ url("hr/employee/data") }}">
<thead>
<tr>
<th dt-field="id"> {{ $model->label("id") }} </th>
<th dt-field="nik"> {{ $model->label("nik") }} </th>
<th dt-field="employee_name"> {{ $model->label("employee_name") }} </th>
<th dt-field="gender"> {{ $model->label("gender") }} </th>
<th dt-field="join_date"> {{ $model->label("join_date") }} </th>
<th dt-field="identity_no"> {{ $model->label("identity_no") }} </th>
<th dt-field="birthdate"> {{ $model->label("birthdate") }} </th>
<th dt-field="idaddress"> {{ $model->label("idaddress") }} </th>
<th dt-col="#dt-action" sort="false" search="false"> </th>
</tr>
</thead>
Where am I doing wrong ? 我在哪里做错了? How do I fix this ? 我该如何解决 ?
I think you missed to select the nik in your select query. 我认为您错过了在选择查询中选择nik的机会。 If that will be done, it should work. 如果可以做到,那就可以了。 When there is any field missing in datatables, it throws this error. 当数据表中缺少任何字段时,它将引发此错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.