Vishaal
141
1
Laravel

Datatable Checkbox Invalid JSON error

Posted 3 months ago by Vishaal

Hello,

I have create datatable with checkboxes now after much try i have write the code in jquery to massremove checkbox. But when i'm executing this jquery its give me error: DataTables warning: table id=datatabel - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1


$(document).on('click', '#deletejobs', function(){
            var id = [];
            $('.checkbox:checked').each(function(){
                id.push($(this).val());
            });
            if(id.length > 0)
            {
                $.ajax({
                    url:"{{ route('aanvragertaken.massremove')}}",
                    method: "get",
                    data:{id:id},
                    success:function(data)
                    {
                        $('#datatabel').DataTable().ajax.reload();
                    }
                });
            }else{
                alert("Please select atleast one checkbox");
            }
        });

jquery for table (this works good):


$(document).ready(function() {
                $('#datatabel').DataTable( {
                    responsive: true,
                    "language": {
                        "lengthMenu": "Records _MENU_ per pagina",
                        "zeroRecords": "Geen resultaat gevonden",
                        "info": "Pagina _PAGE_ van _PAGES_",
                        "infoEmpty": "Geen resultaat gevonden",
                        "infoFiltered": "(filtered from _MAX_ total records)"
                    }
                } );
            } );


<td><input type="checkbox" class="checkbox" value="{{$takenlijst->id}}" name="checkbox[]" /></td>

What i'm doing wrong that i'm getting that invalid json?

Please sign in or create an account to participate in this conversation.