I have a post method which simply update something to my database but there is loophole I have settled this method to button with onclick using javascript and when button clicked it blocks button for other 10 seconds but when I tried with direct URL it doesn't disables button for 30 seconds why ?
here is my post mapping code
@RequestMapping(value = "/Balnce_add", method ={RequestMethod.POST, RequestMethod.GET})
public ModelAndView GoesUp(@AuthenticationPrincipal CustomUserDetails currentuser) throws IOException {
if (isAuthenticated()) {
int x=currentuser.getBalance() +10;
currentuser.setBalance(x);
repo.setUserInfoById(x,currentuser.getId());
repoofdata.setDataInfoById(x,currentuser.getId());
System.out.println(currentuser.getName()+" (new balance) ==> " +currentuser.getBalance());
return new ModelAndView("redirect:"+"/game1"); // here game1 is HTML page with getmapping
}
return new ModelAndView("redirect:"+"/signin"); // here signing is HTML page with getmapping
}
and here is my HTML code with on click javascript function
<button id="upside" onclick="up(true)" type="submit" class="btn btn-success">Up</button>