jquery:datatable save button: always gets the original value instead of updated one

I have a jquery:Datatable with a custom Save button like below:

...,
{
                                text: 'Save',
                                action: function (e, dt, node, config) {
                                    
                                    var json = JSON.stringify(dt.rows().data().toArray());
                                    var dat = $('#MainContent_ddlDate').val();
                                    var cols = ""

                                    dt.columns().header().each(function (e, i) {
                                        var col = jQuery(e).html();
                                        cols += col + ",";
                                    });
                                    
                                   $.ajax({
                                         type: "POST",
                                         url: 'Ranking.aspx/SaveRanks',
                                         data: JSON.stringify({ 'tbldata': json, 'cols':cols, 'surveydate': dat }),
                                         contentType: "application/json; charset=utf-8",
                                         dataType: "json",
                                         success: function (msg) {
                                             window.location.reload();
                                         },
                                         error: function (e) {
                                             Console.log(e);
                                       }
                                   });
                                }
}

Note that in this datatable, all the columns and rows are created in the back-end dynamically based on some values in SQL DB.

My problem is, when I change a value in a cell and click the save button, it always gets the original value instead of the updated one. I could not find out how to fix this issue.

There is no page refresh occurring, it never hits page_load when “save” is clicked..

Any help would be appreciated.

Regards.