Laravel Datatable:Uncaught TypeError:无法读取未定义的属性“length”

时间:2017-03-28 03:29:55

标签: json ajax datatable

我正在尝试从我的数据库中获取数据到数据表。这是我的数据表脚本:

var table = $('#teamTable').DataTable({
         dom: 'Bfrtip', 
         pageLength: 25,   
         "ajax":{
            url :"/teamsPopulate",  
            dataType: 'json',
         },
         columns: [
                { data: "id" },
                { data: "name" },
                { data: "parent_id" },
                { data: "created_at" },
                { data: "update_at" }],
         serverSide     : true,
        "bProcessing": true, 
        select: 'multiple',
        responsive: true,
        altEditor: true,     
        buttons: [{
          text: 'Add',
          name: 'add'
        },
        {
          extend: 'selected',  
          text: 'Edit',
          name: 'edit'        
        }]
 });

这是我的控制器脚本

  public function getTeamContents(){
    $teams = Team::all();
    return response ()->json( $teams );
  }

这是我的观点

<table class="table table-striped table-bordered table-hover dataTables-example" id="teamTable">  
<thead>
  <tr> 
      <th></th><th></th><th></th><th></th><th></th>
  </tr>   
</thead>
<tbody>
  <tr>
    <td></td><td></td><td></td><td></td><td></td>
  </tr>                           
</tbody>
</table>

我哪里出错了?请帮忙。

0 个答案:

没有答案