var warehouseData=[
{
"WarehouseId":1,
"ThirdParyId":301,
"WarehouseName":"香港",
"WarehouseType":"海外仓库",
"WarehouseDesc":"小仓库",
},
{
"WarehouseId":2,
"ThirdParyId":302,
"WarehouseName":"深圳",
"WarehouseType":"本地仓库",
"WarehouseDesc":"大仓库",
},
]
This is the data in the warehouse. Now I want to edit and modify one of the data. I just wrote a function, as follows:
UpdateWarehouse(obj, callback) {
for(var i=0;i<warehouseData.length;i++){
if(warehouseData[i].WarehouseId==obj.WarehouseId){
warehouseData[i] = obj;
}
}
callback({ Success: true });
},
It doesn’t work when called. Could you please tell me if it’s wrong to write it like this?
漂亮男人2017-06-12 09:33:57
There is a problem with the data format. Do not add a comma to the last item of the object
迷茫2017-06-12 09:33:57
I don’t see any grammatical problems in the code. Are you sure it’s not used incorrectly?
三叔2017-06-12 09:33:57
Is there a missing word function
in front of this function?
Then remove the comma, try it
function UpdateWarehouse(obj, callback) {
for(var i=0;i<warehouseData.length;i++){
if(warehouseData[i].WarehouseId==obj.WarehouseId){
warehouseData[i] = obj;
}
}
callback({ Success: true });
} // 刚这里有个逗号