1

I have a jQuery datatable with one of the columns having an edit button. On clicking the edit button I need to take all the values from the selected row to Spring controller .

I am able to get the row data from the datatable but I am not sure how to send this value to the spring controller.

Code for retrieving row data :

$('#example tbody').on( 'click', 'tr', function () {
var data = table.row( this ).data();
} );

1 Answer 1

2

You need to do an ajax request to your controller. Change type as yours i.e. GET, POST

$('#example tbody').on( 'click', 'tr', function () {
var data = table.row( this ).data();
$.ajax({
       url:'your_path_to_post',
       data: {
          data: data //key data should be your model attribute name, value data is your table value.
       },
       error: function() {

       },
       success: function(data) {

       },
       type: 'POST'
    });
} );
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your precise answer..!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.