如何在Laravel 5.1中为文件创建路由?

时间:2015-09-06 12:53:58

标签: jquery json laravel datatable get

我在Laravel 5.1中使用Datatable,当使用jQuery加载Datatable时,我不知道如何为更改语言添加json文件?

我在刀片页面中的代码:

<script>

$(function () {
    dTable = $('#admins').DataTable({
        "responsive": true,
        "processing": true,
        "serverSide": true,
        "ajax": "list_admin_ajax",
        "pagingType": "full_numbers",
        "language": {
            "url": "{{ url('/public/include/Persian.json') }}"
        }
    });
    dTable.order( [ 1, 'desc' ] ).draw();
})

</script>

但是这个错误已经完成了:

http://localhost:8000/public/include/Persian.json 404 (Not Found)

1 个答案:

答案 0 :(得分:0)

您应该使用asset helper

<script>
var language_url = "{{ asset("include/Persian.json") }}";
// ...
</script>

确保文件public/include/Persian.json确实存在。