spring - JSP Catching Event from RadionButton -


i looking onchange listener radiobutton in jsp. using example: https://www.tutorialspoint.com/springmvc/springmvc_radiobutton.htm know how catch event of radiobutton on controller ??

there not exist default way in spring. why want this?

you use ajax call send data of selected button rest controller. similar pseudo-code.

    jquery(document).ready(function($) {       $("#your-buttons").change(function(event) {         event.preventdefault();         var data = formname.your-buttons.value;          $.ajax({             type : "post",             contenttype : "application/json",             url : "your/api/url",             data : json.stringify(data),             datatype : 'json',             success : function(data) {                 display(data);             },             error : function(e) {                 display(e);             }         });        });     }); 

then on rest controller have handle other event.

@requestmapping(value = "/your/api/url", method = requestmethod.post) public string whatever(.....) {     // ... } 

Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -