Determining MVC3 Server Validation Success

When you return from an AJAX request, is there a way to determine if any server-side confirmation has added any errors?

I tried

if ($('#MyForm').valid() == true)
...

in the function OnSuccess, but it is always true, regardless of whether the server-side check fails or not. Updated HTML, if it generates, puts an error on hold, so I know that checking for proper operation.

I suspect that the method valid()simply restarts client-side validation.

+3
source share
2 answers

​​ . . , , revalidate() unbotrusive js

$.validator.unobtrusive.revalidate(form, validationResult);
+1

ajax , Json return.

, , , , , , .

public class MyJsonReposnse
{
   public bool Valid {get;set;}
   public string Error {get;set;}
   public IList<MyClass> Data {get;set;}
}

json onSuccess jQuery, Valid

+2

All Articles