Is there a way to detect and stop if page is reloading.
I have a page which is getting reloaded after successful submission of a form present in it. I want to have an event listener which sees if page is reloading and should stop it from being reloaded.
I cannot return false; for sucessful submit of registration form
In your html:
<form onsubmit="myFunction()">
Enter name: <input type="text">
<input type="submit">
</form>
In your javascript:
myFunction = function(e) {
// prevents default action to happen
e.preventDefault();
// do what ever you want to do here
// i.e. perform a AJAX call
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With