I have one popup modal which submit to an ajax page after validation. Validation and submission are working perfectly. But the only issue, on first click it is not submitting the form or validation.On the second click it is working perfect.
Code:
<script>
$(function () {
$('form').on('submit', function (e) {
e.preventDefault();
$('#gen-bar-form').validate({
ignore: [],
rules: {
firstName: {
required: true
},
editor: {
required: true
}
},
submitHandler: function(form) {
$("#loader-bg").css("visibility", "visible");
$.ajax({
type: 'post',
url: 'action/file.php',
data: $('form').serialize(),
success: function (data) {
var GenTokRet = JSON.parse(data);
$("#gen-msg").html("<p>"+GenTokRet+"<p>");
$("#loader-bg").css("visibility", "hidden");
}
});
}
});
});
});
</script>