Row not updating correctly after AJAX save

Row not updating correctly after AJAX save

rchanderrchander Posts: 1Questions: 1Answers: 0
edited January 2022 in Editor

When using AJAX, after a sucessful save where returned data is in the proper JSON format for success, the row being edited is not being updated, instead another row is being updated with the values being edited and saved. The first edit+save operation behaves properly, but the second edit+save operation results in the wrong row being updated (typlically the row that was edited first).

$(document).ready(function() {
        var table_jpm;
        editor_jpm = new $.fn.dataTable.Editor( {
                ajax: function ( method, url, data, success, error ) {
                        $.ajax( {
                                type: 'POST',
                                url: '/slet/s/rptsave?dbrpt=caasbrkcashactivityreconmtd.jpm&rowid={id}',
                                data: data,
                                dataType: "json",
                                success: function (json) {
                                        success( json );
                                        console.log("Good: " + json);
                                },
                                error: function (xhr, error, thrown) {
                                        error( xhr, error, thrown );
                                }
                        } );
                },
                 table: "#jpm"
                , fields: [
                        { label: '0', name: '0' }, { label: '1', name: '1' }, { label: '2', name: '2' }, { label: '3', name: '3' }
                ]
        } );
        $('#jpm').on( 'click', 'tbody td:not(:first-child)', function (e) {
                editor_jpm.bubble( this, {
                        onBlur: 'submit',
                        submit: 'allIfChanged'
                });
        } );
        var table_jpm = $('#jpm').DataTable( {
                responsive : false
,columns: [
{ data: "0"},
{ data: "1", className: 'editable'},
{ data: "2"},
{ data: "3"}]
        });
});

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Hi,

    Can you show me both the data being submitted to the server and the JSON being returned please?

    Also, do you have id attributes for the tr elements in the table body?

    Thanks,
    Allan

Sign In or Register to comment.