News for hackers. Stuff that matters.
Re:Ask HN: How do you deal with the powerlessness feeling of... by jim_lawless on Tuesday January 04, 2022 @10:44AM (#29795961)
Without seeing any of your code, what I've written below can be considered wild speculation.

I've experienced this kind of page-reload relating to buttons that are of type SUBMIT and no specific ACTION is specified in the FORM tag. Sometimes, the default SUBMIT behavior triggers earlier than an attached Onclick() handler. If there's no ACTION, it reloads the same page.

You might try adding the following attribute to the FORM element:

ACTION="javascript:void(0);"

This should prevent the form from SUBMITting to itself. The job to submit the form then relies on JavaScript code in an event handler to submit the request properly.

You also might try switching the type to BUTTON if you just want to attach an Onclick() handler to it.

There are no comments on this comment yet.