My code is as follows
$.ajax({
type: 'post',
dataType: 'json',
url: '123.123.0.1',
success: function (result) {
for (var i = 0; i < 2; i++) {
console.log('OUTSIDE');
$.ajax({
type: 'post',
dataType: 'json',
url: '123.123.0.1',
success: function (result) {
console.log('INSIDE');
}
});
}
}
});
Result of that code is :
OUTSIDE
OUTSIDE
INSIDE
INSIDE
My Objective here is I want to outside AJAX wait inside AJAX until inside AJAX done then inside AJAX continue. So I wanna the result look like :
OUTSIDE
INSIDE
OUTSIDE
INSIDE
My question :
How to do that? How to fix my code?