2
我正在使用Laravel 5和Bootgrid Pagination。我打算稍後使用它,所以我正在學習它,並且玩弄它,但我無法使它工作。在我的瀏覽器控制檯中,我收到Laravel 5和Bootgrid分頁
Uncaught TypeError: Cannot read property 'length' of undefined
我不知道它是否是我傳遞的數據格式。
這裏的HTML
<table id="grid-data" class="table table-condensed table-hover table-striped" data-toggle="bootgrid" data-ajax="true" data-url="api/deliverytracker">
<thead>
<tr>
<th data-column-id="id" data-identifier="true">ID</th>
<th data-column-id="sender">Sender</th>
<th data-column-id="received">Recieved</th>
</tr>
</thead>
</table>
在我的API路線/ deliverytracker
Route::any('api/deliverytracker', '[email protected]');
然後,我的功能我DeliveryTrackerController
public function deliveryIndexApi()
{
$data = array(
array('id' => '1', 'sender' => '[email protected]', 'received' => '2014-05-30T22:15:00'),
array('id' => '2', 'sender' => '[email protected]', 'received' => '2014-05-30T22:15:00'),
);
return json_encode($data);
}
難道我錯過了什麼?我試圖控制檯登錄我的$數據,事實證明
[{"id":"1","sender":"[email protected]","received":"2014-05-30T22:15:00"},{"id":"2","sender":"[email protected]","received":"2014-05-30T22:15:00"}]
謝謝!