Answer the question
In order to leave comments, you need to log in
PJAX reloads (re-renders) the submit form itself, how to avoid this?
Based on this nix-tips.ru/yii2-primeryaem-pjax-na-activeform-ig... tutorial, I am submitting a form.
Everything is great, but the form is reloading, can this be avoided?
Answer the question
In order to leave comments, you need to log in
Well written here for this occasion
$('body').on('beforeSubmit', ‘form#formId', function () {
var form = $(this);
// return false if form still have some validation errors
if (form.find('.has-error').length) {
return false;
}
// submit form
$.ajax({
url: form.attr('action'),
type: 'post',
data: form.serialize(),
success: function (response) {
// do something with response
}
});
return false;
});
PJAX - pushState + Ajax. A priori, the next page should load.
Just use Ajax forms
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question