javascript - can't push object into array -
this question has answer here: how return response asynchronous call? 21 answers i'm missing basic. i'm grabbing data api , trying push array of json objects. api works fine , i'm getting data, not seem pushed array. can't seem console log of data parameters. here jquery code: var jsonarr =[] var jsondata = {} $.get(apigetlist,function(r) { $(r).each(function(i) { $.get(api_checklist_start + r[i].id +api_checklist_end ,function(s){ $(s[0].checkitems).each(function(k){ jsondata = {"item": [k], "task": r[i].name, "name": s[0].checkitems[k].name, "state": s[0].checkitems[k].state } jsonarr.push(jsondata) }) }) })