简体   繁体   中英

Submit form after success return after ajax call

I validate my form with both client and sever side scripting. First I validate it with jQuery then it goes to php validation and if it returns success or something like that I want to submit the form but some how the condition does not work. However in html err_msg I get success text but its not working.

jQuery.validator.setDefaults({
    submitHandler: function () {
        var name = $na('#inf_field_FirstName').val();
        var password = $na('#inf_field_Password').val();
        var cpass = $na('#cpass').val();
        var email = $na('#inf_field_Email').val();
        var age = $na('#inf_custom_Age').val();
        $na.ajax({
            type: "POST",
            url: '<?php bloginfo('
            template_url ')?>/user_create.php',
            data: 'name=' + name + '&email=' + email + '&password=' + password + '&cpass=' + cpass + '&age=' + age,
            cache: false,
            success: function (result) {
                jQuery('.err_msg').html(result);
                if (jQuery('.err_msg').html == 'sucess') {
                    jQuery("#inform").submit();
                } else {
                    alert('error');
                }
            }
        });
    }
});

use jQuery("#inform")[0].submit();

otherwise, if u have submit button in your form just trigger that button

jQuery("#submit_btn_id").trigger('click')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM