Answer the question
In order to leave comments, you need to log in
Why does the form's submit event occur twice in Yii2?
Good day!
To intercept the form submit event I use the following. code (as a test):
$(document).on("beforeSubmit", "#pm-form", function (event, messages) {
var formdata = $(this).serialize();
console.log(formdata);
$(this).find(':submit').attr('disabled', true);
return false;
});
Answer the question
In order to leave comments, you need to log in
That is, in fact, the call to the beforeSubmit event occurs with a delay.
With what it can be connected? And is it possible to somehow fix it?
I am using the normal js submit event. Everything works fine.
Note tip: Use a FormData object instead of a serialized string to submit the form.
More details here: https://learn.javascript.ru/xhr-forms
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question