I am making nested Ajax call, here is code for that:
function getCheckListId() {
var authToken = getCookie("aqs_authToken");
//Lets say AjaxCall1
$.ajax({
....
// Basic Ajax definition (type, url, etc.....)
....
success: function (result) {
for (var i=0; i< result.length;i++) // ForLoop AjaxCall1
{
var sample= result[i].checklistDetailId;
// Lets say AjaxCall2
$.ajax({
url: 'URL' +sample
// Code for Another Ajax Call
success: function(result) {
for(var i=0; i<result1.length; i++) { { ... Some code.. }
} // END ForLoop AjaxCall2
toSendEmail();
// This is function call in which I am posting data (AjaxCall3)
}, // Success Function close for AjaxCall2
error: function(error) {.. some code.. }
} // Error function close for AjaxCall2
}
}); // Close of AjaxCall2
}, // Success Function close for AjaxCall1
error: function (error) {
alert("Some Statement");
} // Error Function Close for AjaxCall1
});
}
I am making AjaxCall2 in AjaxCall1' Success function. But my AjaxCall2 is not getting executed it is directly making the call to function toSendEmail() I had look around and I tried like making function inside function (nested function) to make my ajax call executed but still not working. Can anyone suggest me any another way to execute it? or What I need to change to get my AjaxCall2 executed BEFORE controller calls toSendEmail() method?
Thank You