I happen to have the following form:
<form method="post" action=<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?> enctype="multipart/form-data">
<button type="submit" name="identifier" value="wikipedea_form">
Add Post
</button>
</form>
I use jquery to submit this form as
$("form").submit();
This doesn't send the post data $_POST["identifier"]. I assume jQuery uses HTMLFormElement.submit() under the hood. The MDN docs say that:
<input>with attribute type="submit" will not be submitted with the form when using HTMLFormElement.submit()...
I think the same applies to the button tag as well. Just to be 100% sure I am asking here. May be it depends on the browser etc etc...
So, Would <button> with attribute type="submit" not be submitted with the form when using HTMLFormElement.submit()? Please quote official documentation to back up your answer.
Only successful controls are submitted in normal form submission.
Submit buttons are only successful if they are used to submit the form (or if the form is submitted via Enter in a single text input in which case the default submit button is successful). This lets you distinguish which button was used to submit the form in cases such as:
<button name="action" value="like">Like</button>
<button name="action" value="dislike">Dislike</button>
Trigging form submission with JS bypasses the selection of a submit button.
For each element field in controls, in tree order:
Then continue.
If you want to submit data with a form every time it is submitted, regardless of how it was submitted: Use <input type="hidden" ...>