How to return this value?
<p>I am building a mobile app using <code>phonegap</code>, <code>jQuery</code> and <code>jQuery mobile</code>. I want to use <code>SqLite</code> database in my app for storing some user information. (I can't use <code>local storage</code> i want to do search/sort operations on the data)</p>

<p>This is the code I am working on to get this done,</p>

<pre><code>function getAccountInformation(){
    var accounts = {};
    db.transaction(function(transaction) {
        transaction.executeSql('SELECT * FROM account;', [], 
            function(transaction, result) { 
                if (result != null &amp;&amp; result.rows != null) { 
                    for (var i = 0; i &lt; result.rows.length; i++) {
                        var item={};
                        var row = result.rows.item(i); 
                        for(var prop in row){
                            item[prop]=row[prop]
                        }
                        accounts[i]=item;
                    }
                }
            },errorHandler
        );
    },errorHandler,nullHandler);
    console.log(JSON.stringify(accounts));
}
</code></pre>

<p>If I put this <code>console.log(JSON.stringify(accounts));</code> after the end <code>}</code> of the <code>for loop</code> it shows proper output.</p>

<p>But if I put it where it is right now the <code>{}</code> is printed as an output.</p>

<p>How can I make <code>getAccountInformation()</code> function return that <code>accounts</code> object to my other function? Where I will use <code>jQuery</code> to render the output.</p>

<p>What I want to do is return this <code>accounts</code> object simply by wrting
<code>return accounts;</code></p>
