I'm using thymeleaf and spring 3 mvc. When I try to perform Ajax POST request I don't understand how can I show a response message from a controller on my html page:
Here's a code snippet:
$.ajax({
type: "POST",
url: "/settings",
data: "request=" + request,
success: function (response) {
$('#msg').replaceWith('<div id="msg" th:text="response"></div>');
},
});
'response' is a i18n message from controller. Now, I want to show this message at using thymeleaf (th:text="response"). Of course, this code does not work, because it thinks that response variable is a plain string.
The question is how to show i18n response message using thymeleaf. Or maybe there are some other methods to show i18n messages on html page (not using jsp) through js?