I am unable to set project activities which are inside clientsData. Here is my scenario
By the time the control reaches inside my callback function of executeSql, values of i and j are maximum possible values because executeSql() is asynchronous function. So when I try to execute following line
clientData[i].projects[j].activities = result.rows;
it gives me error saying "Cannot read property 'projects' of undefined"
Code snippet
for (var i = 0; i < clientData.length; i++) {
for (var j = 0; j < clientData[i].projects.length; j++) {
var getActivities = "SELECT * FROM Activity \n\
WHERE activityID \n\
in \n\
(" + clientData[i].projects[j].activityIds + ")";
tx.executeSql(getActivities, [], function (tx, result) {
clientData[i].projects[j].activities = result.rows;
updateClientData(clientData);
});
}
}