I'm adding data to an indexeddb object store, and my data is in a json array coming from the server like this:
myArray = [[40,'a'],[11,'b']]
So here's my code, and it's working but I'm worried that I'm using a loop:
db = response.target.result
svcTran = db.transaction(['myData'],'readwrite')
myData = svcTran.objectStore('myData')
for (var i=0;i<myArray.length; i++) {
result.id = myArray[i][0]
result.name = myArray[i][1]
svcAdd = myData.add(result)
svcAdd.onsuccess = mySuccess
svcAdd.onerror = myFailure
}
I don't think I should put this inside of a loop. I read early on about using functions inside of loops, like it only executes the last one or something.