I'm trying to update the Model with a background Ajax Post, below is my existing code
Javascript (Jquery)
var url = '@Url.Action("UpdateValue", "MyController")';
$.post(url, $('form').serialize(), function (view) {
//...
});
Controller
[HttpPost]
public ActionResult UpdateValue(MyViewModel model)
{
model.FileName = "NewValue";
return Json(new { success = true });
}
This code posts the existing model to controller and then I'm updating the field FileName, but this does not seem to retain the updated value ("NewValue"). How to make it update the existing model with new value?