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

114
Visualizações
DataTable Refresh with Two Methods

I have two trigger function that used for two functions. end point is once the objective is completed DataTable would be reloading. as per this case, One function is working when the other is not. The not working one's process is a simple add function with a modal popup. once it is added it will be displayed on the datatable real-time. below is the function.

    //DOESN'T REFRESH TABLE

    $(document).on('click','#add',function(event){
        event.preventDefault();
        $('#add-cat').html('');
        var id = $(this).data('id');
        $.ajax({
            type:'POST',
            url:'../cat/modal/add.php',
            data:{id:id},
            success : function(data)
            {
                $('#add-cat').html(data);

                //TO REFRESH TABLE
                $('#example').DataTable().ajax.reload();
            }
        });
    });

The refreshing one real-time as per requirement is below

     //REFRESHES TABLE
     $(document).on('click','#con',function(event){
        if(confirm("Are you sure?")){
            event.preventDefault();
            var id = $(this).attr('data-id');
            $.ajax({
                url     : '../ord/stat.php',
                method  : 'POST',
                data    : {id : id},
                success : function(data)
                {
                    $('#example').DataTable().ajax.reload();
                }
            });
        }
        else{
            return false;
        }
    });

Why the first one is not updating the table and the second one is?

Regards.

about 4 years ago · Santiago Trujillo
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