我想使用 for 循环添加到 JSONStore
所以我在 for 中调用了长度超过 500 的 saveToJSON() 函数,但它没有添加,并且在控制台中它显示成功但是当我查看 jsonstore 时什么也没有,循环次数我调用添加到 jsonstore 是在控制台中的红色气泡中。
function saveToJSON(object) {
var data ={
title : object.title,
subtitle: object.subtitle,
};
var options = {}; //default
WL.JSONStore.get('MyDataCollection').add(data, options)
.then(function () {
//handle success
console.log("add JSONStore success");
})
.fail(function (errorObject) {
//handle failure
console.log("add JSONStore failure");
});
}
最佳答案
不建议在JSONStore中进行并行操作。 JSONtore 被设计为异步工作。您可以使用 for 循环连续运行 JSONStore 操作。但是,您的示例没有显示 for 循环。您是否尝试过使用较小的迭代来执行 for 循环?可能是 2 个而不是 500 个。
关于javascript - 在 workligth JSONStore 中几乎同时保存多次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26048829/