I'm attempting to send a PUT request to the controller using AJAX. Here is my code:
$().ready(function(){
$('#submit').click(function(){
var toUrl = '/users/' + $('#id').val() + '/profile';
$.ajax({
url: toUrl,
type: 'PUT',
contentType: 'application/json',
data: JSON.stringfy({name: 'data'}),
dataType: 'json'
});
});
});
And this is how I am trying to handle it in the controller:
@RequestMapping(method = RequestMethod.PUT, headers = "Content-Type=application/json")
public @ResponseBody String updateProfileInfo(@PathVariable Long id, @RequestBody ProfileForm profileForm){
System.out.println(profileForm.getName());
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!");
return null;
}
I simply want to display something in the console to confirm that the action has occurred, and I'm unsure why it's not working.
Of course, I have the mapping set up in the class:
@RequestMapping(value = "/users/{id}/profile")
public class ProfileController {