prevent refresh of page when button inside form clicked

The Solution to prevent refresh of page when button inside form clicked is


Add type="button" to the button.

<button name="data" type="button" onclick="getData()">Click</button>

The default value of type for a button is submit, which self posts the form in your case and makes it look like a refresh.

~ Answered on 2012-11-07 02:16:04


Most Viewed Questions: