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

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