1

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)

3
  • I think its a typo, for the jquery selector $('#example') you've added a trailing space character which looks like $('#example ') Commented Jun 23, 2016 at 1:33
  • There's more to that error than what you're showing. There's also a number and a link to the documentation. Let's see that. Also, let's see the server side code. Commented Jun 23, 2016 at 7:17
  • the server respond with Failed to load resource: the server responded with a status of 401 (Unauthorized) Commented Jun 23, 2016 at 18:15

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

the problem wasn't that , I tried to rewrite my code and it worked. and effectively there is no need to use "route", thank you for your reply, +1 vote

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.