you can set ajax async: false , example this
// get data 1
$.ajax({
type: "GET",
url: _apiOPD,
dataType: "json",
async: false,
success: function (response) {
console.log(response);
}
});
// get data 2
$.ajax({
type: "GET",
url: _apiUnitOrganisasi,
data: {
opd_id: $('#opd_id').val(),
},
dataType: "json",
async: false,
success: function (response) {
console.log(response);
}
});
// get data 3
$.ajax({
type: "GET",
url: _apiUnitKerja,
data: {
opd_id: $('#opd_id').val(),
unit_organisasi_id: $('#unit_organisasi_id').val(),
},
dataType: "json",
async: false,
success: function (response) {
console.log(response);
}
});