PHP Refresh table contents with ajax

I have a form that contains a table that is dynamically populated with data according to the selected option in the drop-down list.

The drop-down list contains 2 values ​​"enabled" and "disabled". The first column of each row in the table contains a check box. The structure of the table is as follows.

[checkbox ]| user | status

[checkbox1]| jim  | enabled

[checkbox2]| sam  | disabled

The flag value is equal to the user ID.

There is a button for changing the status of selected users.

when the button is clicked, the selected flag value is published using ajax, and the status of the selected users is changed, but the data is updated only when the page is reloaded.

How to update the table when the status changes. Here is my script.

 function Status(){
    var checked = []
    $("input[name='select[]']:checked").each(function ()
    {
        checked.push(parseInt($(this).val()));
    });
    if(checked!=''){

                    $.ajax({
                        type:'post',
                        url:site_url()+'/common/changeStatus',
                        data:{'checked':checked},
                        dataType:'json',
                        async:false,
                        success:function(result){

                            if(result!= "false"){
                                $.msgBox({
                                    title:"Success",
                                    content:"Status change successful"
                                });
                                $(function () {
                                    $('.msgButton').click(function (event) {
                                        event.preventDefault();
                                        $("#table").load($(this).attr("#table"));

                                    });
                                });                                
                            }

Here #tableis the table identifier containing the data.

+5
1

PHP. . JQuery AJAX :

$(".table").html(resultTable);

resultTable - , PHP. , .

+2

All Articles