Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mubeenali's avatar

Yajra DataTables loading data time exceeded from 1 Minut PHP Fatal Error.

I have 15000 records in my users table. I want to use datatable i have followed the data table forum speed faq. But none of them is going to wok for me . Can you please suggest me to decrease the loads time for the effiency of the system .? I am using the datatable latest version 9.8.0. Below is my Client Side Code:

<script>
    $(function() {
        
        var GridView =  $('#users_table').DataTable({
            bprocessing: true,
            bserverSide: true,
            ajax: '{{ route('users.lists') }}',
            deferRender: true,
            columns: [
                { data: 'id', name: 'id' },
                { data: 'name', name: 'name' },
                { data: 'email', name: 'email' },
                { data: 'action', name: 'action'},
                
            ]
        });

        $('#users_table').show();
        GridView.columns.adjust().draw();
    });
    </script>

My Controller Code :

 public function usersLists()
    {
        $users = User::orderBy('id','desc')->get();


        return Datatables::of($users)
                                   ->addColumn('action',function(User $user){
                                     return  `<div class="btn-group btn-group-xs">
                                              <a data-toggle="tooltip" title="" class="btn btn-default" data-original-title="Off"><i class="fa fa-power-off"></i></a>
                                              <a data-toggle="tooltip" title="" class="btn btn-default" data-original-title="Edit"><i class="fa fa-edit"></i></a>
                                             `;
                                   })
                                   ->make(true);
    }

0 likes
1 reply
bobbybouwmann's avatar

You just have too much data for your browser! Instead, you need to use pagination here. This should be on by default.

Also, according to the docs you need to call toJson()

return Datatables::of($users)
    ->addColumn('action', function(User $user) {
        return  '<div class="btn-group btn-group-xs">
            <a data-toggle="tooltip" title="" class="btn btn-default" data-original-title="Off"><i class="fa fa-power-off"></i></a>
            <a data-toggle="tooltip" title="" class="btn btn-default" data-original-title="Edit"><i class="fa fa-edit"></i></a>';
    })
    ->toJson();
}

Please or to participate in this conversation.