I am trying to use Post method in Ajax, but it is not working. It always return Full HTML Page Code.
@PostMapping("api/account/otp/phonenumber")
@ResponseBody
public String getOtpPhoneNumber() {
return "Success!";
}
$.ajax({
type:"post",
url:"/api/account/otp/phonenumber",
success: function(result){
console.log(result);
}
});
But when i use get method, it properly give output.
@GetMapping("api/account/otp/phonenumber")
@ResponseBody
public String getOtpPhoneNumber() {
return "Success!";
}
I am confused, what i am missing!