I have a 2D array which has a bunch of arrays - let's call them inner-arrays. Each inner array has a bunch of URL strings and an associated time-interval value. In other words, all the URL's in a single inner-array has the same time-interval value.
The Javascript sends an AJAX request for each of the inner-arrays at regular intervals, and that interval is actually the aforementioned time interval; and then on the server side some processing is done on the URL's in the inner-array passed, and a result is returned to the Javascript. On the basis of this response, some change is made in the DOM.
And this process goes on forever.
Here is my problem: When I load this program in the browser, the browser keeps running and the page doesn't get loaded fully. But AJAX is supposed to be Asynchronous, isn't it? What am I doing wrong here?
for (var innerArrayKey in outerArray) {
var innerArray = outerArray[innerArrayKey];
setInterval(function() {
$.ajax({
url: "url/of/my/server/script",
method: "post",
data: {innerArray:innerArray},
success: function(...) {
// MAKE SOME CHANGE IN DOM
},
error: function(...) {
...
}
});
}, innerArray[0]["intervalValue"] );
}