Riyas Kp
Riyas Kp

Reputation: 151

How to return the response from jQuery AJAX?

I am working with bootstrapWizard and need to submit a form each step.Submitting forms using ajax and validating the form in server.I need to pass the return value to onNext .But it is always return true.

    $('#buyer_wizard').bootstrapWizard({
            'tabClass': 'form-wizard',
            onTabClick: function(tab, navigation, index) {
                return false;
            },
            onNext: function(tab, navigation, index){
                var url=$("#buyer_form_step"+index).attr('action');
                var data=$("#buyer_form_step"+index).serialize();
                $.ajax({
                        type: 'POST',
                        url:url,
                        data:data,
                        async:false,
                        success:function(data){
                            return data
                        },
                        error: function(data) { // if error occured
                            alert(JSON.stringify(data));
                        },
                        dataType:'json'
                });
            }
    });

onNext is true always and going to next screen even if the ajax return value is false.

Upvotes: 1

Views: 168

Answers (0)

Related Questions