I am just wondering if the document.myForm.submit() is a synchronous call, that will block until finished... or if it is async and will continue to execute without waiting for the submit to return. Thanks for any help.
The form submit() Method in HTML DOM is used to send the form data to the web-server.
The method form. submit() is used for dynamic creation and sending the details to the server. The JavaScript form submission can be used for object creation and various attributes can also be used. The attributes can be class, id, tag, etc.
As the following two examples show, the async and await keywords result in asynchronous code that looks a lot like synchronous code.
The onsubmit event occurs when a form is submitted.
It's an asynchronous call.
However, at some point, the new page will load, and your page will be destroyed.
The browser seems to continue to execute javascript immediately after submitting a form. In this jsFiddle example, the log statement is printed before the form is submitted.
Markup
<form action="foobar"></form>
<button id="submitBtn">Submit</button>
Javascript
var button = document.getElementById('submitBtn');
button.onclick = function() {
document.forms[0].submit();
console.log('after submitting');
};
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