我像这样初始化我的JSON对象:
var car = {"model":"honda","make":""}
我有一个更新make的ajax调用:
function updateCarModel(id) {
$.ajax({
url: '/Car/UpdateModel',
async: true,
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify( id: id)
success: function (data) {
var localClientStorage = window.localStorage;
var carObject = localClientStorage.getItem("car");
carObject = JSON.parse(carObject );
carObject.model = data.Car.Model;
localClientStorage.setItem("car", JSON.stringify(carObject));
}
});
};
当我在chrome控制台中检查carObject时,它会显示原始对象,而不是模型的更新对象。我确实检查了data.Car.Model
是否具有公民价值,而且确实如此。