不执行

时间:2018-06-06 16:26:12

标签: 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.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代码。该设备几乎没有免费存储空间。谁能猜到可能是什么原因?

编辑:

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);
});

0 个答案:

没有答案