I am encountering an issue when trying to navigate between pages. I have a button that triggers an AJAX POST request. Here is an example of the code:
$.ajax({
contentType: "application/json",
type: "POST",
data: JSON.stringify(project),
url: "/saveProject",
success: function (data) {
console.log('done');
},
error: function (jqXHR, textStatus, errorThrown) {
console.log('error while post');
}
});
@RequestMapping(value = "/saveProject", method = RequestMethod.POST)
public @ResponseBody
String saveProject(@RequestBody Project newProject, Authentication authentication) {
projectService.saveProjectNew(newProject, authentication);
return "mywork.html";
}
My goal is to redirect to mywork.html after executing the AJAX call, but currently nothing happens and I remain on the same page. There may be something missing in my implementation that I am not aware of, as I am relatively new to this.