A
A
Alexander Kositsyn2018-02-05 20:15:19
JavaScript
Alexander Kositsyn, 2018-02-05 20:15:19

How to do error handling when the submit event is fired on the form?

There is a form in which there is an action attribute.

form.work-content__form#workForm(enctype="multipart/form-data" action='/api/works' method='post' )

The form is submitted when the button is clicked.
Here I take the "form" element. and call the submit event on the form. How to handle an error or a positive result in such a case?
document.getElementById("workForm").submit();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Perov, 2018-02-05
@SnaIP

Make validation on the client, if everything is good then submit. Get a response from the server success or err and do what you want with it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question