title: How can I prevent refresh of page when button inside form is clicked?
body: <p>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.</p>
  
  <p>My simple code goes like this</p>
  
  <pre><code>&lt;form method="POST"&gt;
      &lt;button name="data" onclick="getData()"&gt;Click&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>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.</p>
  
  <p>What should I do to prevent the page refresh?</p>