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

403
Vistas
DataTables Deferred Loading with WordPress content using templates

I have a table using DataTables.js for a table of custom post types from WordPress with several hundred entries. I am trying to use deferLoading in order to load in the content with AJAX, but have been running into multiple errors.

I have been using this tutorial as a reference. The endpoint seems to be set up properly, because I am able to do a basic AJAX call to it and return the object

    var data;
        $.ajax({
            url: ajax_object.ajax_url + '?action=datatables_endpoint',
        }).done(function(data) {
            console.log(data);
        });

...but when I get to 4. Set up the DataTable it does not load any of the data object into the DataTable.

    var grantDT = $('#grantsList').DataTable({
        serverSide: true,
        processing: true,
        ajax: {
            url: ajax_object.ajax_url + '?action=datatables_endpoint',
            dataSrc: 'data'
        },
        deferLoading: $('#grantsList').data('count'),
        columns: [
            { data: 'ID' },  
            { data: 'post_title' },
        ],

        pageLength: 30,
        lengthMenu: [[30, 60, 90, -1], [30, 60, 90, "All"]],
    });

The other issue I have with this method is the <tr></tr> for each of these rows has custom markup (checkbox to "favorite", etc) as well uses several advanced custom fields that aren't included in the endpoint that I've created.

Is there a way to run deferLoading with php templates being used to add the rows / content to the DataTable? Am I thinking about this the wrong way? Thanks for any help!

about 4 years ago · Juan Pablo Isaza
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