处理依赖的Ajax调用

I have a scenario: I am calling a Ajax function A, Once I get the value from A , I wanted to call another Ajax function B with value from A , in the same way I have to call function Ajax function C. Once I got all the result then I have to compile those value to array. I'm not getting how can I do it

And function A has multiple records so I am iterating it. and once I got all the result then compile it for further action.

function A()
{
     $.ajax({
        url: requestUri,
        contentType: "application/json;odata=verbose",
        headers: requestHeaders,
        success: function (data) {
            if (data.d.results.length > 0) {
                $.each(data.d.results, function (index, e) {
                    "Some value"    
                }
            }
        },
        error: function (data) {
            alert(data.responseJSON.error.message.value);
        }
    });
}
function B()
{
     $.ajax({
        url: requestUri,
        contentType: "application/json;odata=verbose",
        headers: requestHeaders,
        success: function (data) {
            Filter based on "Some value" from function A
        },
        error: function (data) {
            alert(data.responseJSON.error.message.value);
        }
    });
}
function C()
{
     $.ajax({
        url: requestUri,
        contentType: "application/json;odata=verbose",
        headers: requestHeaders,
        success: function (data) {
            Filter based on "Some value" from function A
        },
        error: function (data) {
            alert(data.responseJSON.error.message.value);
        }
    });
}

You need to call the second function inside the success of the first function. Something like -

function A()
{
     $.ajax({
        url: requestUri,
        contentType: "application/json;odata=verbose",
        headers: requestHeaders,
        success: function (data) {
            if (data.d.results.length > 0) {
                $.each(data.d.results, function (index, e) {
                    B("Some value");//changes here
                }
            }
        },
        error: function (data) {
            alert(data.responseJSON.error.message.value);
        }
    });
}

Note that you would also need to change the declaration of the second function to accept this input.

Try Call your B Function inside Your A function and call your C function inside your B function

function A(){

    $.ajax({

    success:function(){
        //your code
        A();
    }
    }); 

}