I want to know how can I retrieve success and model error and display it in my modal if the post is called via ajax? If success modal must close and if error, a modal should display the custom error and not close modal. So far here is my code:
this is called when the user clicks the save button function:
    if (result.value) {
    
                    var actionUrl = form.attr('action');
                    var sendData = form.serialize();
    
                    $.post(actionUrl, sendData).done(function (data) {
    
                        //Error here
                        //what code to retrieve error here?
                        //end error
    
                        //Success here
                        swalWithBootstrapButtons.fire(
                            'Saved!',
                            'Your data has been saved.',
                            'success'
                        )
    
                        PlaceHolderElement.find('.modal').modal('hide');
                        //end success
                    });
                } else if (
                    /* Read more about handling dismissals below */
                    result.dismiss === Swal.DismissReason.cancel
                ) {
                }
}
And here is my controller code:
     [HttpPost]
            [ValidateAntiForgeryToken]
            public async Task<IActionResult> Create(string company, MemberVM member)
            {
                if (ModelState.IsValid)
                {
                    var user = new ApplicationUser { UserName = member.Email, Email = member.Email, SiteName = company, Status=true, DateCreated = DateTime.Now, EmailConfirmed = true };
                    var result = await _userManager.CreateAsync(user, "Password123!");
                    if (result.Succeeded)
                    {
    
                    }
                    else
                    {
                        foreach (var error in result.Errors)
                        {
                            ModelState.AddModelError("", error.Description);
                        }
    
                        return PartialView();
                    }
    }
return PartialView();
    }
And I know my validationscripts are working fine, sample screenshot
