I have the below table. With ajax call I am updating the content of the table. It is reflected in the database, but how can I refresh the table without reloading the entire page. Please someone guide me.
My table structure:
<table class="table table-hover" id="cust-table">
    <thead>
        <tr>
            <th>LastName</th>
            <th>FirstName</th>
        </tr>
    </thead>
    <tbody>
        <?php
            for($i=0; $i<$numrows; ++$i) {
                 $contacts = mysqli_fetch_assoc($result);
            ?>
        <tr>
            <td><?php echo $contacts['LastName']; ?></td>
            <td><?php echo $contacts['FirstName']; ?></td>
        </tr>
        <?php
        } ?>
    </tbody>
</table>
Jquery code:
$.ajax({   
       type: 'POST',   
       url: 'update.php',   
       data: {LastName:last_name, FirstName:first_name}
     });
the update.php is updating the database but I need to refresh the table without refreshing the entire page. Can someone please help me on this?
This should be easy.
    //delete all rows in table
    $('#cust-table').empty();
    //add rows
    $('#cust-table > tbody:last').append('<tr> ... </tr>'); //do the magic
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With