Reload table without refresh with Ajax jQuery

1

I have a table that has the option to update records, but I need to change a record when it changes dynamically in the table without having to refresh. is already working the part of the server it already changes the data and tals .. but I need to refresh the page to be able to see the change made .. I have the following JS:

if(e.update){
    $('#insert_form').each(function(){
         $('.alert').removeClass('alert-danger').addClass('alert-success');
                this.reset();
         });

    // Aqui eu preciso recarregar a tabela..
    $('#employee_table') // Refresh!

}

This is inside a request, and if the return is update it var execute the function that is there inside ..

    
asked by anonymous 24.04.2017 / 19:42

1 answer

1

If you choose to rebuild the table, you could remove the content from tbody and render it again with the jQuery ajax return. Something like:

success: function (result) {     
    $('tbody').empty();
    result.forEach(function(item){
       $('tbody').append('<tr><th>'+item.chave+'</th></tr>');
    })
})
    
24.04.2017 / 19:58