I have a function containing an ajaxSubmit inside. I want it to return a true/false based on the result but it's not working, here the code:
function savePjt(completo){
    completo = completo || 'false';
    $('#pj_form_fields').ajaxSubmit({
        beforeSubmit: function() {
            $('#pjt_submit').val('Loading...');
            $('#pjt_submit').attr('disabled', 'disabled');
        },
        success: function(res) {
            if(res == 'done'){
                if(completo == 'true'){
                    $('#modal_pjt_completo').modal('show');
                    $('#btn_conferma_e_invia').click(function(){
                        $.post(base_url()+'project/completa', {id:$('#id_acquisto').val(), pjt_table:table}, function(resd){
                            return true;
                        });
                    });
                }else{
                    return true;
                }
            }else{
                $('#pjt_submit').removeAttr('disabled');
                alertify.alert(res);
                return false;
            }
        }
    });
}
When I trye to call the function this way:
console.log(savePjt('false'));
The log displays undefined instead of true/false; I even tried returning a number or string but doesn't work...
Any reason I can't see?
 
    