php - Reload Table (NOT Datatable()) after jQuery/Ajax success

one text

Solution:

I am not sure if it's it pretty, you can try to put everything in a function and reinitialize it after a successfull ajax.

$(document).ready(function(){

    initClicks();
    function initClicks() {
        // Delete 
        $('.delete').unbind().click(function(){

            var el = this;
            var id = this.id;
            var splitid = id.split("_");

            // Delete id
            var deleteid = splitid[1];

            // AJAX Request
            $.ajax({
                url: 'system/actions/deleteShift.php',
                type: 'POST',
                data: { id:deleteid },
                success: function(response){

                    if(response == 1){
                        // Remove row from HTML Table
                        $(el).closest('tr').fadeOut(600,function(){
                            $(this).remove();
                        });
                        $("#cardTable").reload(" #cardTable");
                        initClicks();
                    }
                    else {
                        alert('Invalid ID.');
                    }

                }
            });

        });
    }
});

Source