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

205
Vistas
DataTable features not working for Return ajax records

I have a very basic HTML table, The data is from the database. I have now set up a selector and as soon I Select any of the options then an AJAX request to get specific data for a specifically selected location. (To make it easier my query just looks for LocationId=1001 as an example). I now want to return the data and update the DataTable, but unfortunately, the data is returned, and it shows in the table but other DataTable features are not working. Like pagination, Search, and the number of records.

PHP page code

$LocId = '1001';
$sql_Select = "SELECT tbl_employee.EmpId,tbl_employee.FirstName,tbl_employee.LastName,tbl_section.SectionNameEn,tbl_section.SectionNameAr FROM `tbl_employee`,`tbl_section` WHERE tbl_employee.SecId=tbl_section.SecId and tbl_employee.Status='Active' and LocId = '$LocId'";
        $result = mysqli_query($conn, $sql_Select);
        while($row = $result->fetch_assoc()) {
            $rows[] = $row;
          }
        $msg = ["data" => $rows];
        echo json_encode($msg);

Function for Ajax call and return records to view in DataTable

function GetEmployee(){
        var LocId = $('#location').val();

        $('#basic-datatablee').DataTable({
            "destroy": true,
            "processing": true,
            "serverSide": true,
            "serverMethod": "post",
            "ajax": {
                "url": "ajaxpages/get_employee.php",
                "data": {LocId:LocId}
            },
            "columns": [
                    {"data": "EmpId"},
                    {"data": "FirstName"},
                    {"data": "LastName"},
                    {"data": "SectionNameEn"},
                    {"data": "SectionNameAr"},
                ],
            language: {
                searchPlaceholder: 'Search...',
                sSearch: '',
            }
        });
    };
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Need to remove

"serverSide": true,
"servermethod": "post",

Add this ajax call type

"type": "POST",

This will solve the problem

over 4 years ago · Santiago Trujillo 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