I initialize my JSON object like this:
var car = {"model":"honda","make":""}
I have an ajax call to update the make:
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));
}
});
};
When I inspect the carObject in the chrome console, it shows the original object, not the updated one with the model. I did check to see if data.Car.Model has a value of civic and it does.