I am try to use when in a for loop , but the counter can not get correctly,always get 11
for(var ti=0;ti<10;ti++){ $.when(ajaxfunction()).done(function(){alert(ti);},500) }