0
我試圖編寫一個函數來確定html5 websql數據庫表是否爲空。代碼如下。我把警報放在那裏看看發生了什麼。當此功能在底部彈出警報時,首先彈出。儘管表格爲空,但返回值爲false。HTML5數據庫表 - 檢查是否空
function tableisempty() {
tf = false;
query = "SELECT * FROM OLL;";
localDB.transaction(function(transaction){
transaction.executeSql(query, [], function(tx, results){
if (results.rows.length == 0) {
tf = true;
alert ("table has "+results.rows.length+" rows. returning "+tf);
} else {
tf = false;
alert ("table is not empty. returning "+tf);
}
}, errorHandler);
});
alert ("return value is " + tf);
return tf;
}
這真的是HTML5嗎? – GolezTrol
@GolezTrol是的。例如http://diveintohtml5.org/storage.html –
今天我學到了一些東西。 :) – GolezTrol