I'm trying to hide rows from datatable based on a value of a column , hde rows with column actif = 0 using server side processing.
So I'm using th following code
My script :
<script type="text/javascript">
$('#hide').click(function(){
alert("in");
if (!$.fn.DataTable.isDataTable('#datatableRows')) {
// $('#datatableRows').DataTable().destroy();
var table = $('#datatableRows').DataTable({
processing: true,
serverSide: true,
var actif = $(this).attr('actif');
ajax:{
url: "{{ route('castingss.filter_status') }}",
data:actif
},
columns:[
{
data: 'photo',
name: 'photo',
render: function(data, type, full, meta){
return "<img src={{ URL::to('/') }}/castingimages/" + data + " class='list-thumbnail responsive border-0 card-img-left' />";
},
orderable: false
},
{data:'nom',
name: 'nom',
render:function(data,type,full,meta){
return "<a href='profile'>" + data + "</a>";
}
},
{
data: 'cine',
name: 'cine'
},
{
data: "tel1",
name: "tel1"
},
{
data: 'action',
name: 'action',
orderable: false
}
]
});
}
});
</script>
My controller :
function filter_status(Request $request)
{
if(request()->ajax())
{
if($request->actif = 0)
{
$data = DB::table('castings')
->where('actif', array($request->actif = 1))
->get();
dd($data);
}
return datatables()->of($data)->make(true);
}
return view('Casting.castingss');
}
My route :
Route::group(['middleware' => ['auth','role:admin']], function() {
Route::get('castingss/filter_status', [App\Http\Controllers\CastingController::class, 'filter_status'])->name('castingss.filter_status');
});
for the time being I have the folowing error in console :
Uncaught SyntaxError: Unexpected identifier
Updated
there is my network tab->XHR when I clicked on the button Hide
is there something wrong with my code, what is preventing lines from hiding?
Thank you in advance
