Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

331
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda