title: Callback, return value and HTML5 executeSql function
body: <p>I have a big problem. I know it's about callback, closure but I don't know how to solve the problem. Here is my code</p>
  
  <pre><code>$.Model.extend('Article',
  {
       findAll : function(params, success, error){                
                  var result = []
                  db.transaction(function(tx) {
                      tx.executeSql('select * from contents', [],function(tx, rs) {
                          for(var i=0; i&lt;rs.rows.length; i++) {
                              var row = rs.rows.item(i)
                              result[i] = {
                                  id: row['id'],
                                  title: row['title'],
                                  body: row['body']
                              }
                          }
                      })
                  })
                  //here result is undefined
                  alert(result)
                  return result
      }
  })
  //undefined
  var view = Article.findAll
  </code></pre>
  
  <p>I know that executeSql is asynchronous function, but I don't know how to save and return result of executeSql. I use javascript mvc and HTML offline database.</p>
  
  <p>Thank you for your help</p>