iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
✨
How to prevent buttons inside a form tag from triggering submission
When I was trying to integrate two functions into one and wrapped a table tag with a form tag, clicking a button inside the table that performs Ajax communication started triggering a form submission.
I considered not using the form tag and sending the values separately via JavaScript, but I found a solution after reading the following article.
By default, the button tag has type: 'submit'.
Therefore, if you don't specify anything, clicking it will submit the form.
According to this reference, there is also a way to match the id attribute of the form tag with the form attribute of the button tag.
The following article also solves a similar problem.
Discussion