jQuery远程验证阻止提交按钮发布值

In my form, there is 2 submit button (save & exit, next) & remotely checking email address duplication. it's working fine. when submitting a form I'm not getting which submit button is clicked.

form.php

<form method="post" action="" id="user_reg_form" name="user_reg_form">
    <input class="form-control" id="user_id" value="<?php echo ($user->user_id!='')? $user->user_id:'0'; ?>" type="hidden" name="user_id">
    <div class="no-padding">
        <div class="col-md-12">
            <div class="form-group no-margin">
                <label>Email:</label>
                <input type="text" class="form-control" name="email" id="email" value="<?php echo ($user->email!='')? $user->email:''; ?>" maxlength="50">
            </div>
        </div>
    <div class="col-md-6">
        <div class="form-group no-margin">
            <label> Name</label>
            <input type="text" class="form-control" name="name" id="name" value="<?php echo ($user->name!='')? $user->name:''; ?>" maxlength="50">
        </div>
    </div>
    <div class="footer-btn" style="text-align:left;">
        <input type="submit" name="save_exit" id="save_exit" class="btn btn-primary"  value="Save & Exit"/>
        <input type="submit" name="next" id="next"  class="btn btn-success"  value="Next"/> 
        <a href="<?=base_url('home/user')?>" class="btn btn-default">Cancel</a> 
    </div>
</form>

jquery validation code:

$("#reg_form").validate({
    rules: {
        email:{
            required:true,
            remote: 
            {
                url: "<?php echo base_url('home/check_email_duplication')?>",   
                type: "post",
                data: { 'user_id': function() { return $("#user_id").val()},'email': function() { return $("#email").val()}},           
            },
        },
        name: "required",
    },
});

After form submit print $_POST array:

User Controller Action:

public function user_reg()
{
    print_r($_POST);
}

Button 1 Click:

Array ( 
    [user_id] => 14 
    [email] => test@test.com
    [name] => yyyy 
)

Button 2 Click:

Array ( 
    [user_id] => 14 
    [email] => test@test.com
    [name] => yyyy 
)

But I Need below-expected Response in the $_POST array: Need submit button value to find out which submit button.

Button 1 Click:

Array ( 
    [user_id] => 14 
    [email] => test@test.com
    [name] => yyyy 
    [next] => Next 
)

Button 2 Click:

Array ( 
    [user_id] => 14 
    [email] => test@test.com
    [name] => yyyy 
    [save_exit] => Save & Exit 
)

Finally, I found the answer which is worked for me.

There is a change in jquery code. I've added 2 changes ignore: [] & async: false in remote condition this solved my issue.

jquery form validation code:

$("#reg_form").validate({
    ignore: [],
    rules: {
        email:{
            required:true,
            remote: 
            {
                url: "<?php echo base_url('home/check_email_duplication')?>",   
                type: "post",
                data: { 'user_id': function() { return $("#user_id").val()},'email': function() { return $("#email").val()}}, 
                async: false,         
            },
        },
        name: "required",
    },
});

with button type="submit" you are submitting directly your form (it doesnt matter which button you have clicked).

So your button is not input element and that is the reason why you do not see expected value after you submit your form.

You can create hidden field which will fill out some value based on button click and then you know which button you have clicked, or create jQuery function below like

function test() {
    let input1 = $('#input1).val();
.
.
.
$('#form).submit();
} 

and where are your submit buttons change button type that call your function like onClick="return test()"