I want to pass the model from controller to Success method in View and access the properties from the model with json. How do I write and how to access the properties in Success method?
public async Task<IActionResult> Edit( Department department)
{
if (ModelState.IsValid)
{
_genericRepository.Update(department);
await _genericRepository.SaveChangesAsync();
var model = _genericRepository.GetByIdAsync(department.Department_Id);
return Json(new { Message = model });
}
return Json(department);
}
<script>
function Success(data)
{
alert(data.Messge);
}
function Failure() {
}
</script>