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

122
Views
Load data in a DataTable with js

I need that when I click on the <a> tag, I am redirected to the desired page and the data I want is loaded in a data table. This is the code in js:

function listBodega(){

    $.ajax({
            type: "POST",
            url: window.location.pathname,
            data: {
                action:'devices_bodega'
            }, 
            success:function(data){
            
                    $(function () {
                        tblCierre = $('#bodega').DataTable({
                        scrollX: true,
                        // responsive: true,
                        autoWidth: false,
                        destroy: true,
                        deferRender: true,
                        sAjaxDataProp: "", 
                        ajax: {
                            url: window.location.pathname,
                            type: 'POST',
                            data: {
                                'action': 'devices_bodega'
                            },
                            dataType: 'json',
                        },
                        
                        columns: [
                            {"data": "serial"},
                            {"data": "mac"},
                            {"data": "nombre_modelo"},
                            {"data": "nombre_marca"},
                            {"data": "login"},
                            {"data": "recibido"},
                            {"data": "Tipo"},
                            {"data": "EnviadorPor"},
                        ],

                        
                        initComplete: function (settings, json) {

                        }
                    });
                });
            },
            error: function(){
                alert(textStatus+': ' +errorThrown);
            },
        });
}

The href is good , but the function listBodega() is not working. So, how can I make that ajax work? Because the function's ajax doesn't work and it jumps to the error directly.

in HTML:

<a onclick = "listBodega()" href="{% url 'apli:bodega_list' %}" class="nav-link">
about 4 years ago · Juan Pablo Isaza
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!