When I post a JSON to the server and return a normal View string from the Spring controller, my jQuery is not hitting the "success" function.
My Controller:
@RequestMapping(value = MappingConstants.RULE_ASSIGNMENT, method = RequestMethod.POST)
public String saveRuleAssignment(@RequestBody RuleAssignmentCO ruleAssignment) {
// Some controller logic ...
return "redirect:/some/view";
}
As you can see, my controller is simply taking in a JSON object, and returning a String view which is supposed to be parsed by Spring. In my logs, I can see that the view is indeed being hit, but my jQuery post method is not hitting the "success" (nor the "error") function.
My jQuery:
jQuery.ajax({
url: 'ruleAssignment',
type: 'POST',
cache: false,
dataType: 'html',
data: test,
contentType: 'application/json',
error: function() {
console.log('error');
},
success: function() {
console.log('success');
}
});