I'm trying to use WebSQL using html5rocks example. All goes well until I try to do "SELECT * FROM todo"
then there is something not clear to me. Callback returns SQLResultSet
without SQLResultSetRowList
.
Code below I tried in Chrome, Background script (Chrome Extension) and Opera.
Step 1. Opening the database
db = openDatabase("todo", "1.0", "Todo manager", 5 * 1024 * 1024);
Step 2. Creating a table
db.transaction(function(tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS " +
"todo(ID INTEGER PRIMARY KEY ASC, todo TEXT, added_on DATETIME)", []);
});
Step 3. Adding data to a table
db.transaction(function(tx){
var addedOn = new Date();
tx.executeSql("INSERT INTO todo(todo, added_on) VALUES (?,?)",
['todo_text1', addedOn]);
});
Step 4. Selecting data from a table
db.transaction(function(tx) {
tx.executeSql("SELECT * FROM todo", [], function(tx, r){console.log(tx, r)},
function(tx, r){console.log(tx, r)});
});
Can't figure out where I am wrong.