Hello everyone, I am facing a unique situation: In my current view, there is a save button that serializes a form and sends it via Ajax to a JsonResult in the Controller. Within this JsonResult method, I am performing add/edit operations on tables in the database. My query revolves around whether it is feasible to display a confirmation box back in the view based on certain conditions. Below you will find snippets of my code. Thank you in advance for your assistance :)
Below is the snippet of javascript present in my view responsible for sending the form-data to the controller using ajax.
<script>
function submitForm() {
$.ajax({
type: 'POST',
url: '@Url.Action("UpdateEvent", "EventCalendar")',
data: $('#UpdateEventForm').serialize(),
success: function (eventId) {
$('#modal-edit-event').modal('hide');
$('#calendar').fullCalendar('refetchEvents');
}
});
}
This chunk of code represents my Controller logic handling the form-data retrieval:
public JsonResult UpdateEvent(.........)
{
List<Guid> usersChanged = new List<Guid>();
.
.
.
if(usersChanged.Count() > 0)
{
//I would like to trigger a confirmation box at this point
}
.
.
.
return Json(eventId, JsonRequestBehavior.AllowGet);
}
}