Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

418
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!