Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
DataTables auto refresh function doesn't work

I have an issue with the reload function for DataTables.

I am using the following code to load and reload the table (server-side).

$( document ).ready(function() {
    $('#dienst_tabelle').DataTable( {
        "ajax": "getData.php",
        "serverSide": true,
        "bProcessing": true,
        "bPaginate":false,
        "searching": false,
        "paging": false, 
        "info": false,
        "columns": [
            { mData: 'dienstname' } ,
            { mData: 'tagesart' },
            { mData: 'gueltig_am' },
            { mData: 'dienstbeginn' },
            { mData: 'dienstende' },
            { mData: 'zeit' },
            { mData: 'status' },
            { mData: 'button' }
        ]
    });

    setTimeout(function(){
        $('#dienst_tabelle').DataTable().ajax.reload(null, false);
    }, 3000);
});

The table loads successfully, but the reload-function doesn't do anything...

What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I can recreate your problem, if I don't handle the server-side draw parameter correctly.

The documentation for this parameter states:

The draw counter that this object is a response to - from the draw parameter sent as part of the data request.

Every time DataTables sends a request to the server it will increment this integer counter (starting at 1). It is the server's job to ensure that the draw parameter it sends back in its response corresponds to the parameter it received in the request.

So, for example, if you hard-code the draw parameter on the server to 1, then the request generated by setTimeout will have a draw value of 2 and the server will respond with a draw value of 1. This mismatch will result in the response being received, but ignored by DataTables.

The solution is for your server-side code to retrieve the draw value from the request and return that same exact value (as an integer) in the response. You are using PHP, which I do not use - so either you already know how to access request parameters using PHP, or you may need to research that.

(In your case, where you are using GET, then maybe you need to use $_GET or $_REQUEST in your PHP.)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!