'RequestMapping head to know if email exist or not
I use spring boot
I would like to check if an email address alread exist in the system. I created this
@RequestMapping(method = { RequestMethod.HEAD }, value={"/email"})
public ResponseEntity<Boolean> checkEmailexist(@RequestParam String value){
return ResponseEntity.ok(userService.checkIfEmailExist(value));
}
If i check the result of userService.checkIfEmailExist, depending of the value, I get true or false...
Result from the call it's alway undefined
$.ajax({
url: '/email?value=' + usernameValue.value,
type: 'HEAD',
success: function (result) {
console.log(result);
}
});
Solution 1:[1]
Its not an answer but rather a set of steps to check that will (hopefully) help you to find a solution:
- Make sure your annotations are correct - whether the
@RestControllerannotation is used properly, what is the result, etc. - As a generalization of "1" try to understand whether the issue is on server at all For that run CURL query/use postman - whatever on a deployed server and see the result.
- If the issue is on the client side try to understand the status code of the request. I'm not a jquery pro (I understand this is a jquery syntax), but read this question and especially the answer with 'done' method - probably its a better way to work anyway, or at least put a jquery tag on the question so that the relevant people could read it and respond.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mark Bramnik |
