簡體   English   中英

DataTables警告:表格ID = DataTables_Table_0-Ajax錯誤

[英]DataTables warning: table id=DataTables_Table_0 - Ajax error

我在laravel中使用了數據表,並收到以下警告消息:

DataTables警告:表格ID = DataTables_Table_0-Ajax錯誤。 有關此錯誤的更多信息,請參見http://datatables.net/tn/7

我無法從數據庫中的表中獲取JSON數據

這是我的控制器

 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::any("data", "EmployeeController@data");

模型

 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 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>

我在哪里做錯了? 我該如何解決 ?

我認為您錯過了在選擇查詢中選擇nik的機會。 如果可以做到,那就可以了。 當數據表中缺少任何字段時,它將引發此錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM