This question already has answers here:
</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/6538470/jquery-deferred-waiting-for-multiple-ajax-requests-to-finish" dir="ltr">jQuery Deferred - waiting for multiple AJAX requests to finish [duplicate]</a>
<span class="question-originals-answer-count">
(3 answers)
</span>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/5627284/pass-in-an-array-of-deferreds-to-when" dir="ltr">Pass in an array of Deferreds to $.when()</a>
<span class="question-originals-answer-count">
(9 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2019-07-21 09:13:28Z" class="relativetime">9 months ago</span>.</div>
</div>
</aside>
I am creating array from ajax promise and after that I want to run my code. For that first loop each inside that loop ajax promise fetch record and add to the array and On first each loop promise I am running my code but each is promise is complete before array completed
my code
var attendeesId = []
$('.tags-container > div[data-email]')
.each(function() {
getCustomRequest(url).then(function(data) { //ajax promise function
attendeesId.push(data.d.Id)
})
})
.promise()
.done(function() {
console.log(attendeesId) //this runs before and shows empty
})
What I am doing wrong over here
</div>