Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81728

DataTables Client Side Does Not Refresh After Updating Row

$
0
0

I im using DataTables v10 and defined:

      $(document).ready(function() {
        $("#datatable").DataTable({
            language: {
                paginate: {
                    previous: "<i class='mdi mdi-chevron-left'>",
                    next: "<i class='mdi mdi-chevron-right'>"
                }
            },
            drawCallback: function() {
                $(".dataTables_paginate > .pagination").addClass("pagination-rounded");
            },
            responsive: false,
            aaSorting: [
                [ 1, 'desc' ]
            ]
        });
        $("#datatable").css("width", "100%");

        $('#datatable').on('click', 'i.text-success.fas.fa-circle, i.text-danger.fas.fa-circle', function(e) {
        var id       = $(this).closest('tr').find('td:eq(1)').text(),
            payed    = $(this).closest('tr').attr('payed'),
            reseller = $(this).closest('tr').find('td:eq(2)').text(),
            msg      = '';

        if (payed == 1) { msg = 'NOT '; }
        if (confirm('Are You Sure That "' + reseller + '" Have ' + msg + 'Payed?') == true) {
            e.preventDefault();
            $.ajax({
                url: './calculations-api.php?type=1&id='+id,
                success: function(response){
                    $('#datatable').DataTable().draw(false);
                    alert(response);
                }
            });
        } else {
            return;
        }
    });
 });

calculations-api.php return only text message like "Success Payed!" so as you can see i im using client side DataTables...my problem is when i click to update data...data is updated on server side, returned message from calculations-api.php "Success Payed!" and DataTables is not refreshed...so i try this code to refresh DataTable after message is returned from server:

$('#datatable').DataTable().draw(false);
But table is not refreshed...so is there another solution? Reloading page is not solution, only DataTables.


Viewing all articles
Browse latest Browse all 81728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>