1

WebKit (Safari 4+ is my focus) has a feature called Web SQL. Web SQL is specified in the W3C draft. Currently only the asynchronous flavor is supported.

I have a situation where I want to synchronize a few different operations - writing to database (using CREATE TABLE query and then a loop through INSERT queries) and then reading from the database. How do I do this? I googled and read a lot of tutorials, but did not find any explanation of that.

If I can't find answer to this, I shall try the Worker feature and if unsuccessful I plan to store the data in webstorage (localstorage) instead.

4

3 に答える 3

1

この問題の解決策をブログに書きました。それがあなたの問題に当てはまるかどうかはわかりませんが、見てください。 http://wander-mind.blogspot.com/2011/03/how-to-synchronize-html5-websql-with.html

于 2011-03-27T08:49:00.613 に答える
0

成功のコールバックを介して操作を連鎖させます。そうすれば、操作の順序を確認できます。この記事にあるサンプル コードを参照してください。

トランザクション オブジェクトまたは個々のクエリで使用できるコールバックを使用できますtx.executeSql(sql, [], callback, errorCallback)

var sql_createTables = "CREATE .....",
  sql_inserts= "INSERT .....";

function errorHandler(tx, error) { 
  //do error handling
}

db.transaction(
 function(tx){
  tx.executeSql(sql_createTables,[], function(tx, result){
     //The table was created
    tx.executeSql(sql_inserts,[], function(tx, result){
       // Inserts completed
    });
  },
  errorHandler);
 }, function(error) { alert("Oh, noes! The whole transaction failed!"); },
 function() { alert("Yeah, baby! We did it."); });

WebWorker はこれとは何の関係もありません。WebWorkerは DOM にアクセスできないため、localStorageWebSqlはその一部です。

于 2013-08-07T12:14:01.610 に答える
0

誰もこれに答えないようです。私の現在の理解では、ローカルストレージにブロックを保存するのが最善です

于 2010-10-18T10:41:43.937 に答える