Addressing the issue of HTML form being closed too soon to transmit SUBMIT request