Trying to make ajax call but not working

Trying to make ajax call but not working

kingharrisonkingharrison Posts: 1Questions: 1Answers: 0
edited January 2015 in Free community support

I am trying to have DataTables make an ajax call to a route that responds with JSON. The route looks exactly as expected but DataTables is not making a call to the route to get the data. It works fine with the basic setup. In developer tools on network I don't see it making the call. What am I doing wrong? code listed:

$(document).ready(function() {
    $('#example').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": "/json/nightjoblog/index"
            
          }         
        });
} );

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    Hi,

    Thanks for posting up the code. It looks like there is a small syntax error in the code above - a "spare" } immediately after the ajax option.

    Perhaps try:

    $(document).ready(function() {
        $('#example').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "/json/nightjoblog/index"   
        });
    } );
    

    If that doesn't work, could you check the debug console in your browser, and if there is an error reported let me know. If there are no errors, perhaps you could run the debugger over the table and let me know the debug code so I can have a little look and see what DataTables is doing!

    Thanks,
    Allan

This discussion has been closed.