I have a view in which there is a registration form generated using the Ajax.BeginForm () helper:
<div id="register_form"> @using (Ajax.BeginForm("Register", "Account", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "register_form", OnFailure = "onFailure", OnSuccess = "onSuccess", OnBegin = "onBegin" } , new { @class = "well form-horizontal" })) { // Html-код формы } </div> In case of successful execution of the Ajax request, the onSuccess script is triggered, the code of which is shown below:
var onSuccess = function (result) { // Код обработчика } How in the onSuccess script to prevent updating the element with the id "register_form", which is specified as UpdateTarget in the AjaxOptions helper that generates the form?
An action similar to the preventDefault () method is required.
UpdateTarget must be specified in this form, since both PartialView can come from the server to update the form, as well as a JSON message about the form filling error.