我正在使用以下代码
var Year12=new Array();
GetYear(function(Year12)
{
alert(Year12);
});
function GetYear(callback)
{
var selectAllStatement = "SELECT DISTINCT year FROM mytable";
var db = openDatabase("Postit", "1.0", "Notebook", 200000);
var dataset;
alert("1");
db.transaction(function(tx) {
alert("2");
tx.executeSql(selectAllStatement, [], function(tx, result)
{
alert("3");
dataset = result.rows;
for (var i = 0, item = null; i < dataset.length; i++)
{
item = dataset.item(i);
Year12[i]=item['year'];
}
callback(Year12);
});
});
}
这里 tx.executeSql 语句没有被执行意味着警报 3 没有显示。有什么办法可以做到这一点