I've found many questions regarding users that requires to execute nested ajax call, but I can't understand if it is a good choice or not to nest them.
Most people tell to "divide" in multiple functions, for example:
function firstCall() {
$.ajax({
// [...]
onSuccess: function(response){
secondCall();
}
});
}
function secondCall() {
$.ajax({
// [...]
onSuccess: function(response){
thirdCall();
}
});
}
function thirdCall() {
$.ajax({
// [...]
onSuccess: function(response){
andSoOn();
}
});
}
- Is this the only solution?
- What are the main problems of nested ajax calls?
I'm developing a web application that requires a lot of ajax interation and sometimes I have to nest the ajax calls, for example to retrieve data that depends on first ajax call result in order to refresh DOM elements
- Should I move everything to the back-end?