我将laravel中的项目存储在子目录中,并且我正在使用数据表,但是,当我想恢复信息时,我得到了典型的错误"无效的json" ,我的项目网址如下
http://www.loupper.com/loupper-b/public/
但我得到的答案是这个
看来,路线还没有占据子目录" loupper-b / public /" ,我怎么能将子目录添加到网址?http://www.loupper.com/subcategory/data 绘制= 1&安培;柱%5B0%5D%5Bdata%5D =对号&安培;柱%5B0%5D%5Bname%5D = ID&安培;柱%5B0%5D% 5Bsearchable%5D =假安培;柱%5B0%5D%5Borderable%5D =假安培;柱%5B0%5D%5Bsearch%5D%5Bvalue%5D =安培;柱%5B0%5D%5Bsearch%5D%5Bregex%5D =假安培;列%5B1%5D%5Bdata%5D = subcategoria&安培;柱%5B1%5D%5Bname%5D = subcategoria&安培;柱%5B1%5D%5Bsearchable%5D =真安培;柱%5B1%5D%5Borderable%5D =真安培;柱% 5B1%5D%5Bsearch%5D%5Bvalue%5D =安培;柱%5B1%5D%5Bsearch%5D%5Bregex%5D =假安培;柱%5B2%5D%5Bdata%5D = categoria&安培;柱%5B2%5D%5Bname% 5D = categoria&安培;柱%5B2%5D%5Bsearchable%5D =真安培;柱%5B2%5D%5Borderable%5D =真安培;柱%5B2%5D%5Bsearch%5D%5Bvalue%5D =安培;柱%5B2%5D% 5Bsearch%5D%5Bregex%5D =假安培;柱%5B3%5D%5Bdata%5D =动作&安培;柱%5B3%5D%5Bname%5D =动作&安培;柱%5B3%5D%5Bsearchable%5D =假安培;柱%5B3%图5D%5Borderable%5D =假安培;柱%5B3%5D%5Bsearch%5D%5Bvalue%5D =安培;柱%5B3%5D%5Bsearc H%5D%5Bregex%5D =假安培;为了%5B0%5D%5Bcolumn%5D = 1&安培;为了%5B0%5D%5Bdir%5D =降序&安培;开始= 0&安培;长度= 10安培;搜索%5Bvalue%5D =安培;搜索%5Bregex%5D =假安培; _ = 1505922295346
这是我的代码,jquery
$(function () {
$.noConflict();
user_tbl = $('#categoria-table').DataTable({
processing: true,
serverSide: true,
order: [[1, 'desc']],
ajax: {
url: '/category/data',
data: function (d) {
d.filter = $('select[name=filter]').val();
},
},
columns: [
{data: 'checkmark', name:'id', orderable: false, searchable: false},
{data: 'nombre', name: 'nombre'},
{data: 'action', name: 'action', orderable: false, searchable: false, class:"text-center"}
]
});
$('#search-form').on('submit', function(e) {
user_tbl.draw();
e.preventDefault();
return false;
});
});
laravel
public function indexDatatable()
{
$categoria=DB::table("categoria")->select("id","nombre")->get();
return Datatables::of($categoria)
->addColumn('action', function ($categoria) {
return '<button onClick=deleteCategoria('.$categoria->id.'); type="button" class="btn btn-xs btn-danger" data-id="'.$categoria->id.'"><i class="glyphicon glyphicon-trash"></i></button><a href="/categoria/edit/'.$categoria->id.'" class="btn btn-xs btn-primary f-left"><i class="fa fa-pencil"></i></a>';
})
->editColumn('checkmark', function($categoria) {
return '<input type="checkbox" id="chk" name="chk[]" class="case" value="'.$categoria->id.'">';
})
->rawColumns(['checkmark','action'])
->make(true);
}
答案 0 :(得分:0)
您可以使用url('/category/data')
让它运行。
user_tbl = $('#categoria-table').DataTable({
processing: true,
serverSide: true,
order: [[1, 'desc']],
ajax: {
url: '{{url('/category/data')}}',
data: function (d) {
d.filter = $('select[name=filter]').val();
},
},
columns: [
{data: 'checkmark', name:'id', orderable: false, searchable: false},
{data: 'nombre', name: 'nombre'},
{data: 'action', name: 'action', orderable: false, searchable: false, class:"text-center"}
]
});
答案 1 :(得分:0)
固定。我只需删除第一个斜杠:
ajax: {
url: 'category/data',
}