简体   繁体   English

DataTables警告:表格ID = DataTables_Table_0-Ajax错误

[英]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.

相关问题 DataTables警告:表格ID = DataTables_Table_0-第0行请求的未知参数“ 4” - DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter '4' for row 0 数据表警告:表 id=DataTables_Table_0 - 为第 0 行第 7 列请求了未知参数“公司名称” - Datatables warning: table id=DataTables_Table_0 - Requested unknown parameter 'business name' for row 0, column 7 DataTables警告:table id = dataTables - Ajax错误。 404未找到 - DataTables warning: table id=dataTables - Ajax error. 404 Not Found DataTables 警告:表 id=datatable - Ajax 错误。 使用 laravel - DataTables warning: table id=datatable - Ajax error. Using laravel 错误:DataTables警告:表id = example-使用DataTables服务器端AJAX请求的未知参数 - Error: DataTables warning: table id=example - Requested unknown parameter using DataTables Server-side AJAX DataTables 警告:table id=table - Ajax 错误。 有关此错误的更多信息,请参阅 http://datatables.net/tn/7 - DataTables warning: table id=table - Ajax error. For more information about this error, please see http://datatables.net/tn/7 DataTables 警告:表 id=products - Ajax 错误。 有关此错误的更多信息,请参阅 http://datatables.net/tn/7 - DataTables warning: table id=products - Ajax error. For more information about this error, please see http://datatables.net/tn/7 数据表,数据库服务器端处理和“数据表警告(表ID =&#39;示例&#39;)” - DataTables, database serverside processing and “DataTables warning (table id = 'example')” 数据表警告表 id=datatables-example - 无效的 json 响应 - Datatables warning table id=datatables-example - invalid json response DataTables警告:表id = table-timsheet-Ajax错误。 有关此错误的更多信息,请参见http://datatables.net/tn/7 - DataTables warning: table id=table-timsheet - Ajax error. For more information about this error, please see http://datatables.net/tn/7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM