加载时laravel datatable json错误

时间:2016-10-31 18:15:41

标签: json laravel datatable

我使用laravel datatable packag e并在加载视图页面时显示此错误 在firefox浏览器中

DataTables warning: table id=rules_table - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

控制器(datatablesController)

<?php

class DatatablesController extends Controller
{

    public function getIndex()
    {
        return view('datatables');
    }



    public function anyData()
    {
        $rule =Rules::select(['id','name','description']);

        return Datatables::of($rule)->make();

    }
}

我的routes.php文件:

Route::controller('datatables', 'DatatablesController', [
    'anyData'  => 'datatables.data',
    'getIndex' => 'datatables',
]);

查看页面:(datatables.blade.php)

            <table class="table table-striped hover" id="rules_table">
                <thead>
                <tr>
                    <th><span class="fa fa-ils"></span>ID</th>
                    <th><span class="fa fa-neuter"></span>Name</th>
                </tr>
                </thead>
            </table>

        </section>
    </section>
    <script>
        $(document).ready(function () {
            var table = $('#rules_table').DataTable({
                processing: true,
                serverSide: true
        });
        });
    </script>

如何解决这个问题?

0 个答案:

没有答案