Jquery 在Parse.com中保存对象时出现无消息的奇怪错误
最近几周我一直在使用Parse,因为我一直在创建一个可以保存一些“产品”的应用程序。到目前为止,它一直运行良好,但我发现了一个奇怪的bug,我无法调试它,也无法找到它失败的原因 简化一下,我有一张这样的桌子:Jquery 在Parse.com中保存对象时出现无消息的奇怪错误,jquery,parse-platform,save,runtime-error,Jquery,Parse Platform,Save,Runtime Error,最近几周我一直在使用Parse,因为我一直在创建一个可以保存一些“产品”的应用程序。到目前为止,它一直运行良好,但我发现了一个奇怪的bug,我无法调试它,也无法找到它失败的原因 简化一下,我有一张这样的桌子: +------+------+-------+-------+ | Name | Type | Price | Stock | +------+------+-------+-------+ | Foo | Bar | 1.00 | true | +------+------+-
+------+------+-------+-------+
| Name | Type | Price | Stock |
+------+------+-------+-------+
| Foo | Bar | 1.00 | true |
+------+------+-------+-------+
| Name | Type | Price | Stock |
+------+------+-------+-------+
| Foo | Bar | 1.00 | true |
+------+------+-------+-------+
| Baz | Coo | 2.00 | true |
+------+------+-------+-------+
| Sun | Low | 3.00 | true |
保存代码通常与de文档相同:
“saveProducts”:函数(){
到目前为止,这一切都很顺利,因为所有对象都是这样的:
+------+------+-------+-------+
| Name | Type | Price | Stock |
+------+------+-------+-------+
| Foo | Bar | 1.00 | true |
+------+------+-------+-------+
| Name | Type | Price | Stock |
+------+------+-------+-------+
| Foo | Bar | 1.00 | true |
+------+------+-------+-------+
| Baz | Coo | 2.00 | true |
+------+------+-------+-------+
| Sun | Low | 3.00 | true |
进入控制台:
f {_serverData: Object, _opSetQueue: Array[1], attributes: Object, _hashedJSON: Object, _escapedAttributes: Object…}
_allPreviousSaves: b.Promise
_changing: false
_escapedAttributes: Object
_existed: true
_hasData: true
_hashedJSON: Object
_opSetQueue: Array[1]
_pending: Object
_previousAttributes: Object
_saving: 0
_serverData: Object
_silent: Object
attributes: Object
changed: Object
cid: "c133"
createdAt: Thu May 14 2015 15:31:25 GMT+0200 (CEST)
id: "XBMruz5vZb"
updatedAt: Thu May 14 2015 15:31:26 GMT+0200 (CEST)
__proto__: f
如您所见,有一个id
和一个createdAt
字段
但是当我试图保存一个Stock
设置为false
的文件时,我得到:
f {_serverData: Object, _opSetQueue: Array[1], attributes: Object, _hashedJSON: Object, _escapedAttributes: Object…}
_escapedAttributes: Object
_hasData: true
_hashedJSON: Object
_opSetQueue: Array[1]
_pending: Object
_previousAttributes: Object
_serverData: Object
_silent: Object
attributes: Object
changed: Object
cid: "c135"
__proto__: f
没有id
,没有createdAt
。我得到的错误是:
[false]
句号。如果我创建了相同的对象,并将Stock
设置为true
,它会很好地保存它
你知道为什么会这样吗
编辑
这是我的方法的扩展版本:
'saveProduct': function() {
// Gets data
var data = this.getDataFromForm();
if(this.validateData(data)) {
var name = data[0],
type = data[1],
price = data[3],
stock = data[4];
var productData = {'name' : name,
'type' : type,
'price' : Number(price),
'stock' : stock
};
var product = new window.app.Product();
// window.app.Product is defined as a Model:
// window.app.Product = Parse.Object.extend("Product", { ... });
// And here comes the Parse save function
product.save(productData, {
...
});
}
}
更新2
这是我打印股票时得到的:
false
它是一个布尔值,不是字符串
这是我在打印productData
时得到的结果:
Object {name: "Foo", type: "Bar "…}
name: "Foo"
price: 1
type: "Bar"
stock: false
__proto__: Object
您如何将其设置为true
或false
?您确定代码实际将其设置为false
正确吗?我将使用该信息更新问题!我看不到您在任何地方使用Parse.Object
。请查看抱歉,我使用了更多信息更新了问题。我正在使用PARe、 对象,我没有显示它。@BjörnKaiser我没有任何云代码。至少我自己没有。