1.a.blade.php
submit a form
action="a_1"
网页.php
路线::get('a_1', 'CodoController@a_1');
CodoController
public function a_1(Request $request) { $search = $request->all(); $result=DB:query() ->select... ->get(); return view(b_1) ->with('result',$result); }
b_1.blade.php
<table class="table table-bordered" id="users-table"> <thead> <tr> <td>Id</td> <td>Name</td> </tr> </thead> </table> <script> $(function() { $('#users-table').DataTable({ processing: true, serverSide: true, ajax:?????<-----How to write this place to receive the $result collection? columns: [ { data: 'id', name: 'id' }, { data: 'name', name: 'name' } ...... ] }); });
是 Route:: 类吗?可以在控制器上使用吗?以及如何在 ajax 上编写脚本:???? 地方。我尝试将这些写入 Codocontroller
use DataTables;
public function a_1(Request $request)
{
$search = $request->all();
$result=DB:query()
->select...
->get();
Route::get('b_1', function() {
return DataTables::collection($result)->toJson();
});
路由可以写在控制器上吗?我得到的错误是
Class Route cannot find.
如果它是正确的用法。
b_1.blade.php 视图下面的脚本如何接收集合?
<script>
$(function() {
$('#users-table').DataTable({
processing: true,
serverSide: true,
ajax:?????<-----How to write this place to receive the $result collection?
columns: [
{ data: 'id', name: 'id' },
{ data: 'name', name: 'name' }
......
]
});
});
</script>