I am using Spring 2.5 (XML based configuration) .In my Spring controller how can i return a string back to my AJAX request? My ajax code is as follows:
jq("#editAdTextSave").click(function() {
alert( "Handler for .click() called." );
jq.ajax({
url: 'bookingDetail.html',
type: 'POST',
data: 'action=updateAdText',
success: function(data) {
//called when successful
alert(model);
//$('#ajaxphp-results').html(data);
},
error: function(e) {
//called when there is an error
//console.log(e.message);
}
});
});
COntroller onSubmit requires a ModelAndView object return value.However I only require to return a string.How could I do that.Please suggest.
You need to use
@ResponseBody
in your mapping method. Using@ResponseBody
would write the value you return toHttpResponseBody
and will not be evaluated as view. Here's quick demo: