How do I process a form submit using asynchrony?

  • 0
    There is a form with a button (type = 'submit'), an EventListener ('submit', handleFormSubmit) hangs on the button. Inside the asynchronous function handleFormSubmit, you need to write a code that will make a modal window visible with certain information with a button, by clicking on which the form will be submitted. The question is how to make the form submission "freeze" until the button is pressed in the modal window:
    async function handleFormSubmit(e) {
    // ???
    JavaScript Jacob Frey, May 3, 2019

  • 2 Answers
  • 0
    No way. No frost in javascript.

    You just interrupt the submit ( preventDefault () ), show the modal, and after clicking the button inside the modal, manually call the submit of this form again, this time without interfering.

    (one call from another can be distinguished by setting a certain flag or simply by some event property, the same isTrusted )

  • 0
    Anna Morse

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!