I am trying to get the value from an inner function. Why is domain always returning undefined? I think this is because the webSQL executes asynchronously. I need to get the value of domain at this point in the program before I can proceed. I think this is a closure problem but perhaps my approach is is just wrong?
var domain = selectDomain();
function selectDomain()
{
var sql,
i;
sql = "SELECT * FROM Domain";
database.open();
database.query(sql, [], function(tx, result)
{
for (i = 0; i < result.rows.length; i++)
{
var domain = result.rows.item(i);
return domain.Domain;
}
});
}