I am experiencing an issue with an AJAX post request.
$.ajax({
type: "POST",
contentType: "application/json",
url: "/rating/save",
data: JSON.stringify(rating),
dataType: "json",
mimeType: "application/json",
success: function (responseData) {
console.log(responseData);
window.location.href = "/welcome"
},
error: function (responseData) {
console.log(responseData);
}
});
Controller
@Controller
public class RatingController {
........
@RequestMapping(value = "/rating/save",method = RequestMethod.POST)
public ResponseEntity<Object> saveRating(@RequestBody List<RatingDTO> ratingDTO) {
return new ResponseEntity<>(ratingService.save(ratingDTO),HttpStatus.OK);
}
}
Despite the fact that there are no exceptions in the response from the controller, I continuously receive the following error:
status: 405
statusText: "error"
The error message indicates that the method is not allowed, even though the service associated with this endpoint is functioning correctly.