Currently, I am working on an MVC5 project where a View is calling a Partial View.
Within the Partial View, there is an Ajax.BeginForm
that triggers a function on OnSuccess
.
However, during execution, I encounter an error stating that the function cannot be found.
Interestingly, if the function is defined in the Parent View, it is located and executed without any issues.
Below is the code snippet for my Partial View:
@model TableAvivaVoz.Models.UserPasswordView
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
@{
ViewBag.Title = "Actualizar";
AjaxOptions ajaxOpts = new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
OnSuccess = "exito",
// OnFailure ="failure",
};
}
@section Scripts {
<script type="text/javascript">
function exito(result) {
alert(1);
}
</script>
}
@using (Ajax.BeginForm("ChangePassword", "Users", ajaxOpts, new { id = "FormID" }))
{
@Html.AntiForgeryToken()
"modal-header">
<h4 class="modal-title" id="myModalLabel">
Cambio de Contraseña
</h4>
</div>
<div class="alert alert-success hidden">
Success! Password Changed.
</div>
@Html.HiddenFor(model => model.User_id)
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="modal-body">
...
[Remaining HTML code for the form structure]
...
}
The issue arises when trying to call the function from the Partial View. What could be missing in this case?
Your assistance is greatly appreciated!