Javascript 不执行
我在将文档放入本地数据库时遇到问题 我使用的代码如下:Javascript 不执行,javascript,local-storage,pouchdb,Javascript,Local Storage,Pouchdb,我在将文档放入本地数据库时遇到问题 我使用的代码如下: var localDB = new PouchDB("db_local", {auto_compaction: true}); localDB.put(poi, function callback(err) { if (!err) { if (networkState == Connection.NONE || navigator.onLine == false) navigator.notification.ale
var localDB = new PouchDB("db_local", {auto_compaction: true});
localDB.put(poi, function callback(err) {
if (!err) {
if (networkState == Connection.NONE || navigator.onLine == false)
navigator.notification.alert(i18n.t("messages.contributionSuccessNoInternet"), contributionSuccess, "Land Cover Collector", i18n.t("messages.ok"));
else
navigator.notification.alert(i18n.t("messages.contributionSuccess"), contributionSuccess, "Land Cover Collector", i18n.t("messages.ok"));
}
else {
navigator.notification.alert(i18n.t("messages.errorStorage"), null, "Land Cover Collector", i18n.t("messages.ok"));
remotePointsDB.put(poi, function callback(err) {
if (!err)
navigator.notification.alert(i18n.t("messages.contributionSuccess"), contributionSuccess, "Land Cover Collector", i18n.t("messages.ok"));
else
navigator.notification.alert(i18n.t("messages.error") + " " + err, null, "Land Cover Collector", i18n.t("messages.ok"));
});
}
});
奇怪的是,没有任何警报发生,而且这种情况只发生在我拥有的一台设备上。我正在使用Chrome浏览器,并使用Cordova为Android编译代码。该设备几乎没有可用存储空间。有人能猜出原因是什么吗
编辑:
是否有任何回调行被命中?
navigator.notification.alert
和i18n.t
通常在此回调之外工作吗?@WillCain是的,这些工作正常。为了确保本地数据库不工作,我在回答中编辑了代码。在这种情况下,我获得了“远程成功”,但没有其他。看起来本地put完全被忽略了。正如我之前所说的,这种情况只发生在一台Android设备上(在另外3台Android设备上测试过,iPad和一台Linux桌面)。您是否启用了调试模式来查看它的说明<代码>数据库.debug.enable('*')代码>。缺少错误消息令人沮丧;听起来像是设备、数据库或交互中的错误。但是浏览器的存储限制因浏览器和操作系统而异;没有标准@我现在试过了。我看到了:PockDB:api db_local+3m put PockDB:api+12ms put PockDB:http GET+4ms PockDB:http put+211ms/PockDB:api+7s put成功{ok:true,id:“x”,rev:“1_x”}
localDB.put(poi, function callback(err, response) {
if (!err)
alert("local success");
else
alert("local: " + err);
});
remotePointsDB.put(poi, function callback(err, response) {
if (!err)
alert("remote success");
else
alert("remote: " + err);
});