0

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

Milind
  • 1,855
  • 5
  • 30
  • 71

0 Answers0