Stop an loading Ajax Spinner after unknown amount of ajax requests.

Stop an loading Ajax Spinner after unknown amount of ajax requests.

Hello, 

I have a service that I am calling an unknown amount of times per each page requests. When the page loads I have a loading spinner running. 

Before, when I had one ajax requests, I would just stop the loading spinner at the end of that request, usually in the ".done()". Yet this time, I do not know how many calls will happen.  I have something like this, 

for(var i = 0; i < requests_times ; i++){
   $.ajax({
        url : 'ServiceRequestUrl'
    }).done()
       .error()
}

Now, how would i be able to tell, that when the last ajax request is done, to hide the loading spinner. I have all the requests running asynchronously because they each are populating an area in the website. 

I know I can use promises, but I can only use it if I know the exact requests being made, for example : 
$.when( $.ajax('url1'), $.ajax('url2') ).then(function(){ //do something })

If I would be able to pass an array to then $.when object then I believe I would be ok, but after reading the docs I do not believe I could. 

If someone could please help, I would greatly appreciate it.