我正在使用jquery datatable从外部cdn
使用它<script src="http://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
我的桌子是
<table class="table table-bordered data-table" id="blocked_list">
<thead>
<tr>
<th>User Name</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
</table>
并在jquery函数中调用它
@section('script')
<script>
$('#blocked_list').DataTable({
"ajax": "{{ route('user.sold_products') }}",
"columns": [
{ data: 'id' },
{ data: 'buyer_id'},
{ data: 'seller_id' },
]
});
</script>
@endsection
这里我认为我做得很好但是我的表格中没有显示的数据和我从控制器调用的数据是:
public function all(){
$user = Auth::user();
$block = Block::all();
$bl = Block::where('buyer_id',$user->id)->get();
return Response::json([
'data' => $block
], 200);
}
我的控制器在数据变量
中包含以下值{"data":[{"id":1,"seller_id":12,"buyer_id":11,"email":"","created_at":"2017-06-01 11:37:54","updated_at":"2017-06-01 11:37:54"},{"id":2,"seller_id":10,"buyer_id":11,"email":"","created_at":"2017-06-01 14:20:51","updated_at":"2017-06-01 14:20:51"}]}
当myy laravel表中没有显示这些值时,我知道为什么有人可以帮助解决这个问题。