jQuery Trigger Form Submit with Parameters

Posted on April 16, 2020 at 9:59 am

You can submit a form using jQuery .trigger() function:

$('#myForm').submit(function (e, pass_through) {
    if(typeof bypass_checks == 'undefined' || bypass_checks == false) {
        // Do some Ajax checks here
        $('#myForm').trigger("submit", [true]);

This way when you call .submit() the same code will not be re-called (else it will end up in possibly an infinite loop) because we use a custom parameter on .trigger() call (see the pass_through variable).

More info on jQuery .trigger() function:


Receive updates via email

Other Posts

Updated Posts