In my Thymeleaf template I have this:
<a href="#" class="ajaxCall">Activate</a>
I have following in my JavaScript:
<script type="text/javascript">
$(document).ready(function(){
$('body').on('click','.ajaxCall' ,function(event){
event.preventDefault();
alert('Ajax call made....!!!');
event.preventDefault();
$.ajax({
type : "DELETE",
url : '/activateUser/',
success: function (result) {
console.log("Activation Successful..");
},
error: function (e) {
console.log("Error ... Activation unsuccessful.!!");
}
});
});
});
</script>
and following in my @Controller:
@RequestMapping(value="/activateUser/{id}", method=RequestMethod.DELETE,
produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value=HttpStatus.OK)
@ResponseBody
public AppUser activateAppUser(@PathVariable Long id) {
appUserJPARepository.setAppUserAsActiveById(id);
return null;
}
Now, the ajax call goes fine but everytime I see this in the console:
DELETE http://localhost:8080/activateUser/ 404
send @ jquery.min.js:2
ajax @ jquery.min.js:2
(anonymous) @ tableusers:2019
dispatch @ jquery.min.js:2
v.handle @ jquery.min.js:2
Error ... Activation unsuccessful.!!
Feeling lost here. What I am missing OR what could be the reason?