I'm sending a POST request to my Spring MVC controller. I've been tweaking the code for hours and getting diverse errors from the controller, such as 400, 404 or 415.
Finally, now my POST request is working (as the controller logs all the data to the console), but the Ajax success
callback is never triggered but the fail
check function always is.
My Ajax request:
$.ajax({
'type': 'POST',
'url': '/iQuality/post-test',
'data': $("#wizard-form").serializeJSON(),
'dataType': 'json',
'headers': {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
'success': function(){
console.log('mandarina');
}
})
.fail(alert("Error!"));
My Spring controller:
@RequestMapping(value = "/post-test", method = RequestMethod.POST, headers = { "Content-type=application/json" })
@ResponseStatus(value = HttpStatus.OK)
private @ResponseBody void handleWizardPost(@RequestBody WizardForm1 wf){
logger.debug("[post-test] : Called route");
logger.info(wf.getSistema());
logger.info(wf.getNombrePase());
logger.info(wf.getEsAtipico());
}
BTW, the controller is supposed to send an empty response (I want the view to stay in the same page, no page refresh).