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

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

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 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