【发布时间】:2016-06-22 03:21:43
【问题描述】:
我第一次使用datatable 和Laravel 5,所以我尝试使用此代码,我在ajax 上获取数据,但无法在datatable 上显示数据。
任何想法如何将响应数据加载到数据表。
这是我的结构:
结果:
路线:
Route::get('admin/pages/datatable', 'admin\PagesController@getDataTable'); // Pages (Static Pages)
pages.blade.php:
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title">Pages Table</h3>
</div><!-- /.box-header -->
<div class="box-body">
<table id="example32" class="table table-bordered table-hover">
<thead>
<tr>
<th>PageId</th>
<th>Title</th>
<th>Text</th>
<th>MetaKeywords</th>
<th>MetaDescription</th>
<th>PostedBy</th>
</tr>
</thead>
<tfoot>
<tr>
<th>PageId</th>
<th>Title</th>
<th>Text</th>
<th>MetaKeywords</th>
<th>MetaDescription</th>
<th>PostedBy</th>
</tr>
</tfoot>
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->
</div><!-- /.col -->
</div><!-- /.row -->
</section><!-- /.content -->
PagesController.php:
public function getDataTable()
{
$Pages = new Pages();
return $GetAllPages = $Pages->GetPages();
}
Pages.php:
public function GetPages()
{
return DB::table('pages')->select('PageId', 'Title', 'Text', 'MetaKeywords', 'MetaDescription', 'PostedBy')
->get();
}
【问题讨论】:
标签: php jquery laravel datatable laravel-5