I'm develop a web app and I have an existing database.I'm trying to getting the data from database using WebSQL but getting error as "ExceptionReferenceError: tx is not defined "
code:
var databaseSync = null;
try
{
databaseSync = openDatabase("database", "1.0", "Database", 10 * 1024 * 1024);
databaseSync.transaction(function(tx){
tx.executeSql('SELECT distinct(Subject) FROM Data', [], function (tx, cb_results){
var len = cb_results.rows.length;
var results = [];
for (i = 0; i < len; i++)
{
var row = cb_results.rows.item(i);
$("#list").append('<li><a href="#" id="">'+ row.Subject +'</a></li>');
$("#list").listview('refresh');
}
}, function(){console.log("Transaction success");}, function(tx, error){console.log("Error" + error.message);});
});
}
catch (e) {
// TODO: handle exception
console.log("Exception" +e );
}
Appending the results in the listview but not getting.
Thanks in Advance.
Try something like this:
Also, why only 2MB database?
-- edit --
OK, here is an example of a function, as used in a live project:
Maybe you can see something you missed.