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

126
Visualizações
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 à 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