Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

324
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda