jquery - Strange error without message when saving an object in Parse.com -
i have been using parse last weeks have been creating app save "products". has been working fine now, found strange bug cannot debug or find reason why failing.
simplifying, have table this:
+------+------+-------+-------+ | name | type | price | stock | +------+------+-------+-------+ | foo | bar | 1.00 | true | the code saving is, in general, same de documentation:
'saveproducts': function() {
// products // validate products // save products product.save(null, { success: function(product) { console.log("saved"); console.log(product); }, error: function(product, error) { console.log("error"); console.log(product); console.log(error); } }); until now, have been working fine because objects this:
+------+------+-------+-------+ | name | type | price | stock | +------+------+-------+-------+ | foo | bar | 1.00 | true | +------+------+-------+-------+ | baz | coo | 2.00 | true | +------+------+-------+-------+ | sun | low | 3.00 | true | getting in console:
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 as can see, there id , createdat fields.
but when tried saving file stock set false get:
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 no id, no createdat. , error this:
[false] full stop. , if create same object stock set true instead, saves fine.
any ideas why happening?
edit
this extended version of method:
'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 defined model: // window.app.product = parse.object.extend("product", { ... }); // , here comes parse save function product.save(productdata, { ... }); } } update 2
this when print stock:
false it boolean, not string.
this when print productdata:
object {name: "foo", type: "bar "…} name: "foo" price: 1 type: "bar" stock: false __proto__: object
Comments
Post a Comment