I want to use following ajax method to call a java function (I use Spring Boot and Hibernate) and read the return value afterwards. The function '/myFunction' is correctly called and the return value is a string and is correctly logged in the java function. But I don't get it, how I can use the return message from the java-method in the success-part afterwards. (notifyUser is a little function(title, message) that shows a notification to an user, this function works correctly) By now, notifyUser just post Error [object Object]
$.ajax({
        type : 'POST',
        contentType : 'application/json',
        url : '/myFunction',
        data : JSON.stringify({
            fooM,                   
            fooO,
            fooS
        }),
        dataType : 'json',
        cache : false,
        timeout : 600000,
        success : function(data) {
            notifyUser('Info', data);
        },
        error : function(e) {
            notifyUser('Error', e);
        }           
    }); 
@RestController
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
public class MyController {
@RequestMapping(value = "/myFunction", method = RequestMethod.POST)  
public String myFunction(@RequestBody MyRequestClass request ) {
String return_string = "Check if return value works " + request.getFooM() + request.getFooO() +request.getFooS();
    log.debug(return_string)
    //Up to this step, everything works
    return return_string;
}
}
What do I have to change, that I'm able to get the return value of the called function '/myFunction' in the success part and send the string to notifyUser? Thank you for your answers. Phil