I have an issue while using buttons inside form.
(我在使用表单内的按钮时遇到问题。)
I want that button to call function.(我想要那个按钮来调用功能。)
It does, but with unwanted result that it refresh the page.(它确实如此,但是有了不必要的结果,它刷新了页面。)
My simple code goes like this
(我的简单代码是这样的)
<form method="POST">
<button name="data" onclick="getData()">Click</button>
</form>
On clicking the button, the function gets called with page refreshed, which resets all my previous request which affects the current page which was result of the previous request.
(单击该按钮时,将在页面刷新时调用该函数,该页面将重置我以前的所有请求,该请求会影响当前页面,这是前一个请求的结果。)
What should I do to prevent the page refresh?
(我该怎么做才能阻止页面刷新?)
ask by bunkdeath translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…