Question: I have written a script i JQuery and PHP,
After the success return from PHP, AJAX function should catch a success response but I am not getting that.
Below is the code: 

```
$.ajax({

                    url     :"script_admin-add-category.php",
                    method  :"POST",
                    data    :{lExpensesId:lcl_ExpensesId},

                    success:function(data){
                        //if(data=="ok"){
                            if(data=="YES"){
                                alert("EMAIL");
                            }else{
                                alert(data);
                            }
                        //}
                        //if(data=="ok"){
                            //alert("Expenses Id already exists!");
                        //}else{
                            //alert(data);
                        //}
                    }

        });

```

and here is the php code

```
//Check connection
    if(!$conn){
        die("Connection Failed: " .mysqli_connect_error());
    }else{
//echo "helloooo";
            if(isset($_POST["lExpensesId"])){
                $lExpensesId    = $_POST["lExpensesId"];
                    $Lquery = "SELECT ExpensesId FROM tblexpensestype WHERE ExpensesId = '$lExpensesId'";
                    if($query_result = mysqli_query($conn, $Lquery)){

                            if(mysqli_num_rows($query_result )){
                                echo 'YES';
                            }else{
                                //echo "Proceed";
                            }
                    }else{
                        echo "Not Okay";
                    }
            }else{

            }
    }       

```

I can see the echo value on browser and alert value also. But if condition is not working for success function???

Answer: 
You are immediately invoking the functions when you pass them in. When you reference the submit functions, you don't need to include the `()` after the function name. `this.updateSubmit().bind(this)` should be `this.updateSubmit`. You also don't need the bind here.

Change: `this.props.handleSubmit(this.updateSubmit().bind(this))`

To: `this.props.handleSubmit(this.updateSubmit)`
I discovered that I needed to do two things.

1. Invoke the custom submit method using this line: `this.props.handleSubmit((values)=> this.submitUpdate(values))()` Note the added "()" at the end.
2. Move this line (and a surrounding if condition) to the componentDidUpdate() method. I'm using props in the submit method to decide the state of validation of the component and the props from mapStateToProps are not assigned to this.props before `componentWillReceiveProps` or `componentWillUpdate`.

Here is my new automatic submit call:

```
componentDidUpdate() {

 //moved this here so that this.props is updated from nextState
 if (this.props.updateMyConfigState == "ValidationFulfilled" 
            && this.props.updateMyConfigValidationClean) {

        this.props.handleSubmit((values) => this.submitUpdate(values))();            

 }
}

```

I am aware that this is outside of the redux-form recommendation for validation and I recognize that this this might not be the best way to handle validation. My current reasoning is: 

1. It allows me to have multiple submission validation actions (separates ones for create and update user actions) where each has their own error and warnings behavior. In particular, Error: disallow action and WarningsOnly: allow but require extra user approval.
2. Visually present the errors/warnings in a separate list outside of the gui elements.