The problem is that rather like an AJAX request, Chrome performs its database transactions (as coded) asynchronously. i.e. the data doesn't exist yet when it starts executing the query. This code should work: