I am trying to use AJAX to send form data to my controller. Here is what I have attempted so far..
My JavaScript function
<script>
function sendDataToController(){
$.ajax({
type: "POST",
url: "./sendData",
success: function(data){
console.log("SUCCESS ", data);
},
error: function(e){
console.log("ERROR ", e);
}
});
}
</script>
My Controller
@RequestMapping(value = "/sendData", method = RequestMethod.POST )
public String processFormData(HttpServletRequest request) throws ParseException {
}
I'm not sure where I'm going wrong as I am encountering the following error in the controller:
org.springframework.web.servlet.PageNotFound handleHttpRequestMethodNotSupported WARNING: Request method 'POST' not supported
Any help to resolve this would be greatly appreciated.