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

439
Vistas
Uncaught TypeError: Cannot read property 'url' of undefined in DataTables

I am getting this error in the console which is not letting me perform my task of fetching the values into the datatable. I will post my code below:

$(document).ready(function() {
    var product_id = '<?php echo $product->product_id; ?>';
    var table = $('table.container-fluid').dataTable({
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": "agent/order/getProduct",
            "data": { "pid": product_id }
        },
    });
    $('#selectProduct').click(function() {
        var id = $("#selectproduct").val();
        var product = ('agent/order/getProduct?product_id=' + id);
        table.ajax.url(product).load();
        table.reload();
    });

Below please find the controller code:

public function getProduct () {
    $prod_id = $this->input->post('pid');
    $this->load->model('order_m');
    $prod = $this->order_m->getProductById($prod_id);
    echo json_encode($prod);
} 

In chrome when I check the issue, it points out to this: table.ajax.url(product).load();

Can anybody please help me with this issue?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

In DataTables 1.10 naming convention has changed, see API for more information.

You need to initialize your table as $("#logTable").dataTable() with lower case d to get access to previous version API or with $("#logTable").DataTable() with upper case D to get access to newer API.

Initialize your table using DataTable() not dataTable() as shown below:

var table = $('table.container-fluid').DataTable({
    // ... skipped ...
});

Alternatively, if you need to have access to older API and initialize with dataTable(), you can call newer API methods as shown below:

var table = $('table.container-fluid').dataTable({
    // ... skipped ...
});

table.api().ajax.url(newURL).load();
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