I have my project in laravel stored in a subdirectory and I am using datatables, however, when I want to recover the information, I get the typical error "invalid json" , my project url is as follows
http://www.loupper.com/loupper-b/public/
but the answer I get is this
http://www.loupper.com/subcategory/data?draw=1&columns%5B0%5D%5Bdata%5D=checkmark&columns%5B0%5D%5Bname%5D=id&columns%5B0%5D%5Bsearchable%5D=false&columns%5B0%5D%5Borderable%5D=false&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=subcategoria&columns%5B1%5D%5Bname%5D=subcategoria&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=categoria&columns%5B2%5D%5Bname%5D=categoria&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=action&columns%5B3%5D%5Bname%5D=action&columns%5B3%5D%5Bsearchable%5D=false&columns%5B3%5D%5Borderable%5D=false&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=1&order%5B0%5D%5Bdir%5D=desc&start=0&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1505922295346
it seems, the route has not taken the subdirectories "loupper-b/public/" ,how could I add subdirectories to the url?
this is my code, 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);
}