我想你已經在數據庫中創建了一個表,並且你已經用2列「id」&「serverURL」將它命名爲「tablename」;其中「id」是主鍵。
試試這個:
Iquery = "INSERT INTO 'tableName' VALUES(null, "+serverURL+");";
tx.executeSql(
Iquery,
null,
function(){ /* to do on success, or you may just set it as "null" */},
function(){ /* to do on error, or you may just set it as "null" */});
,或者你可以試試這個:
tx.executeSql("INSERT INTO tableName(id, serverURL) VALUES (?,?)",
[null, serverURL], // these are the variables to insert
function(){ /* to do on success, or you may just set it as "null" */},
function(){ /* to do on fail, or you may just set it as "null" */});
您可以參考原documentation of cordova以獲得更多信息。