How to check that JQUERY AJAX call is completed

How to check that JQUERY AJAX call is completed

I have a page where I have to bind the few controls via ajax call. Country drop down, state drop down on the basis of selected country, city drop down on the basis of selected city. Nested data binding is working fine.

But If I have some initial values of country, state, city & I have to set the selected values, then this is not working. I am calling a function to set initial values like below:

function bindandsetvalues(_country, _state, _city){

  // function to bind countries via ajax call. ajax logic is inside this function
  bindcountries();

  if($("#country").length > 0){
    // set selected country
    $("#country").val(_country);

    // function to bind states via ajax call. ajax logic is inside this function
    bindstates(_country);

    if($("#state").length > 0){
      // set selected state
      $("#state").val(_state);
    }
  }
}

But only country drop down is populated. Neither initial value of country sets nor state drop down binds.

I have also found the reason. After calling bindcountries() function, control goes to the bindcountries() function. But there is a asynchronous ajax call inside bindcountries() function, so after calling the ajax call, control gets back to the caller function without waiting for the completion of ajax call where I called

$("#country").val(_country);

But because ajax async call is still in progress & country drop down will be bind & render after completing the ajax call.

So, Neither initial value of country sets nor state drop down binds. So, My question is: Is there any way to check or wait for the completion of AJAX async call, so that I will check the existence of rendered control ($("#state").length > 0) after that that time/completing ajax call.

I know there is are .done, .fail & .always methods of jquery ajax where I can handle post ajax call logic. But in my above case, I can't use those methods. There are more than eight this type of nested controls which I have to set/bind.
& all those dropdown has their respective "change" event also which bind the next child control, But Initially I have to set some initial values.

Please suggest me a solution.