javascript - Methods to encapsulate data changes and saves
某草草
某草草 2017-06-12 09:31:57
0
3
651
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?

某草草
某草草

reply all(3)
漂亮男人

There is a problem with the data format. Do not add a comma to the last item of the object

迷茫

I don’t see any grammatical problems in the code. Are you sure it’s not used incorrectly?

三叔

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 });
}  // 刚这里有个逗号
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template