I am attempting to add items to a database migrated from parse using javascript. Code is as follows:
function Item(args) {
args = args || {};
this.catId = args.catId || "";
this.cost = args.cost || "";
this.purchaseDate = args.purchaseDate || "";
this.purchaseDateView = args.purchaseDateView || "";
this.itemName = args.itemName || "";
this.itemCode = args.itemCode || "";
this.scale = args.scale || "";
this.itemQty = args.itemQty || "";
this.location = args.location || "";
this.brand = args.brand || "";
this.description = args.description || "";
this.loanedTo = args.loanedTo || "";
this.notes = args.notes || "";
this.photodata = args.photodata || "";
}
function _newItem(e) {
var itemmonth = $("#item_form .itemmonth").val(),
itemday = $("#item_form .itemday").val(),
itemyear = $("#item_form .itemyear").val(),
itemdate = itemyear + "-" + pad(itemmonth, 2) + "-" + pad(itemday, 2);
console.log(itemdate);
var itemObj = new Item(
{
catId: $("#catId").val(),
cost: +formatCurrency($("#price").val()),
purchaseDate: { "__type":"Date", "iso": itemdate + "T16:19:38.000Z" },
purchaseDateView: itemdate,
itemName: $("#itemName").val(),
itemCode: $("#itemCode").val(),
scale: +_getScaleVal(),
itemQty: +$("#itemQty").val(),
location: $("#location").val(),
brand: $("#brand").val(),
description: $("#description").val(),
loanedTo: $("#loanedTo").val(),
notes: $("#notes").val(),
photodata: $(".photodata").attr("data-img")
});
Backendless.Persistence.of(items).save(itemObj);
}
When the newItem method is called I get an error in the chrome console (see screenshot).