Rajeun
Rajeun

Reputation: 721

Error datatable with laravel and mysql :DataTables warning: table id=example - ajax error

I'm using datatable in my laravel application. When I have one record everything is well and the data is displayed in the data table but when I have more then two records for example I get this error :

DataTables warning: table id=example - ajax error

Some times its works well but when I refresh the page I get the same error, this is my script:

   <script>
    $(function() {
        $('#example').DataTable({
            processing: true,
            serverSide: true,
            ajax: '{{ URL::route('ADMIN-AJAX-USERS') }}',
            columns: [
                { data: 'companyName', name: 'companyName' },
                { data: 'email', name: 'email' },
                { data: 'companyNum', name: 'companyNum' },
                { data: 'statut', name: 'statut' },
                { data: 'created_at', name: 'created_at' },
                { data: 'action', name: 'action', orderable: false, searchable: false}
            ]
        });
    });
</script>

UPDATE:

the server respond with this error: Failed to load resource: the server responded with a status of 401 (Unauthorized)

Upvotes: 1

Views: 1521

Answers (1)

user6458835
user6458835

Reputation:

I just noticed ajax: '{{ URL::route('ADMIN-AJAX-USERS') }}', maybe I am mistaken but I think you can't use both url and route.You have to choose one.

Upvotes: 1

Related Questions