I'm trying to make an ajax request recursively upon each success response that is returned from each request Would I be prone to stack overflows? If so do you have any better way of doing this? My requirements is to initially perform an ajax request and if the json returned is not done perform another ajax request with the same parameters... etc until i get a done flag.
go: function (r) {
Ext.Ajax.request({
url: 'bleh',
success: function (response) {
var data = Ext.decode(response.responseText); // decode json into object
r.update();
if (!data.isDone) go(r);
}
});
}
This is not actually recursion so there is no danger of stack overflow. It may look like recursion, but because the ajax call is asycnchronous, your go()
function only starts the ajax call and then the go()
function finishes right away while the ajax call is underway. Thus, the success handler is called long after the go()
function has already finished. so, it's not actually recursion and there is no stack buildup.
It may look like recursion from the visual effects of the code, but because the ajax call is asynchronous and the success handler is called long after the go()
function has returned, there is no stack buildup.