I am trying to write something that could do the following in that particular order: (1) submit a form (2) print "Print me." (3) wait 3 seconds (4) print "Print me too."
Why doesn't my code accomplish this?
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms));}
function submitForm() { return new Promise(resolve => document.getElementById('form').submit());}
async function test() {
wait submitForm();
console.log("Print me.")
wait sleep(3000);
console.log("Print me too.")
};
test();
<form id="form" type="hidden">
<input value="" id="id" type="text">
<input value="Submit" type="submit">
</form>