同步完成AJAX

I have an AJAX call within another AJAX call.

I am using $.ajax method:

$.ajax({
    type: 'POST',
    url: '/xx/xxx',
    success: function (data) {
        if(data == true){
            var j = MethodThatCallAjaxFunction();
            //some code here
        }
    }    
});

How can I ensure the value of j is filled before I execute code after the comment //some code here?

You can't. MethodeThatCallAjaxFunction can either by syncrhonous (bad), or you can attach a callback to it.

function mtcaf() {
    return $.ajax();
}
//snip
if (data == true) {
    mtcaf().done(function () {
        //some codes here
    });
}