ajax data fails to load, and then it loads

ajax data fails to load, and then it loads

tomishtomish Posts: 17Questions: 11Answers: 0
edited March 2017 in Free community support

Hi, dataTables has been working great for me for years but recently I've had issues loading an ajax call in my file.

A regular ajax calls work fine on my server:

  $.ajax({
     url: "php/thebdl.php",
     context: document.body
  }).done(function() {
    $( this ).addClass( "done" );
  });

But in this context, it does not. Then a day or two later it does. I have copied and pasted code between applications that do work many, many times but no luck. I do not receive any error messages from dataTables. No error messages in my webserver log. I can go in and set a console log in the body below and it fires, so I know the code block is running. I have deliberately removed a comma in the code block below and I get an error message in the console.

$('#my_table').DataTable( {

   dom: 'Bfrtip',
     buttons: [
          'copy', 'csv', 'excel', 'pdf', 'print'
      ],

      lengthMenu: [[25, 50, 75, -1], [25, 50, 75, "All"]],
            "iDisplayLength": 25,


   ajax: {
      url: "php/thebdl.php",
      dataSrc: ""
   },
      columns: [
      { 'data': 'emp_id' },
      { 'data': 'last_name' },
      { 'data': 'first_name' },
       { 'data': 'check_amount' },
       { 'data': 'region' },
        { 'data': 'check_date' }
  ]
   } );
  } );

Apparently someone else is having the same issues and experience (recently too - this posting was last month)

http://stackoverflow.com/questions/42178026/datatables-fails-to-load-ajax-data-source-objects

Thanks! Tom

Answers

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin

    Hi Tom,

    Can you link to the page showing the issue so I can check it out please? I don't immediately see anything wrong with the above initialisation code.

    Allan

This discussion has been closed.