I am currently working on a migration procedure that may last between 2 to 3 days to complete. My concern is that the implementation I have in place could potentially result in a StackOverflow exception due to its recursive nature. I am questioning whether JavaScript generates a large stack to execute this code effectively. Considering that I will need to call this service approximately 10 million times, what would be a more efficient implementation that you would recommend?
function mainFunc() {
var url = getMyUrl();
$.ajax({
url: url,
type: "POST",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (remaining) {
if(remaining > 0) {
mainFunc();
}
else {
alert('done');
}
},
error: function (x, e) {
alert('error!');
}
});
}