When this ajax call is executed and hits the server-side everything works as it is expected, but the problem is that no error or success is returned. In other words neither the success or the error is triggered in the ajax call definition.
Ajax
$.ajax({
type: "POST",
url: "programBuilder",
data: formObjCreator(),
contentType: "application/json; charset=utf-8",
cache: false,
processData: false,
dataType: "json",
beforeSend: function(xhr) {
xhr.setRequestHeader(header, token);
},
success: function(data){
alert("asd")
},
failure: function(errMsg) {
alert(errMsg);
}
});
}
Controller
@RequestMapping(method = RequestMethod.POST) private String doPost(@RequestBody final ProgramBuilderCommand command, BindingResult result, Model model,
RedirectAttributes redir){
if(result.hasErrors()){
model.addAttribute("message",result.getAllErrors().get(0).getDefaultMessage());
return VIEW;
}
long programID = commandPersistenceService.saveCommand(command);
redir.addFlashAttribute("message", "Settings has been updated.");
redir.addAttribute("eventID", command.getEventID());
redir.addAttribute("programID", programID);
return "redirect:" + URL + "?programID=" + programID + "&eventID=" + command.getEventID();
}