LYiub
7 months ago
76
15
Laravel

DataTables warning: table id=student_table - Ajax error. http://datatables.net/tn/7 with Yajra Laravel

Posted 7 months ago by LYiub

I just used Yajra (datatable "yajra/laravel-datatables": "^1.0" ) on laravel (5.4.16), PHP version 7.1 .

I got this error while loading :

DataTables warning: table id=student_table - Ajax error. For more information about this error, please see http://datatables.net/tn/7

and on inspect:

jquery.js:8526 GET http://127.0.0.1:8000/leads/testing?draw=2&columns%5B0%5D%5 500 (Internal Server Error)

this is my app.php:

        Yajra\DataTables\DataTablesServiceProvider::class,

AND

    'DataTables' => Yajra\DataTables\Facades\DataTables::class

and I tried to make the ' Y ' small letter but still have the same error.

My controller :

use DataTables;

class LeadsController extends Controller
{
   public function gettesting()
    {

        return view('testing');
    }


    public function testing()
    {
        $students = Meeting::select('name', 'details');

        return DataTables::of($students)->make(true);

    }
}

my route is as follows:

Route::get('testing', '[email protected]');
Route::get('leads/testing', '[email protected]')->name('leads.testing');

My view 'testing' :

<!DOCTYPE html>
<html>
<head>

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <link  href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>

</head>
<body>

<div class="container">
    <br/>
    <br/>
    <div align="right">
        <button type="button" name="add" id="add_data" class="btn btn-success btn-sm">Add</button>
    </div>
    <br/>
    <table id="student_table" class="table table-bordered" style="width:100%">
        <thead>
        <tr>
            <th>name</th>
            <th>details</th>
        </tr>
        </thead>
    </table>
</div>


<script>

    $(document).ready(function () {
        $('#student_table').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "{{ url('leads/testing') }}",
            "method": "GET",
            "columns": [
                {"data": "name"},
                {"data": "details"}
            ]
        });

    });

</script>


</body>
</html>

Please help me to solve it

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