How to dispatch on the result of submiting an AJAX form in ASP.Net MVC?

Posted by J. Pablo Fernández on Stack Overflow See other posts from Stack Overflow or by J. Pablo Fernández
Published on 2009-05-31T17:47:12Z Indexed on 2010/03/25 6:03 UTC
Read the original article Hit count: 213

Filed under:
|
|

In ASP.Net MVC, having a form more or less like this:

<% using (Ajax.BeginForm(new AjaxOptions() { OnSuccess="onSuccess"})) {%>
  <p>
    <label for="Comment">Comment:</label>
    <%= Html.TextArea("Comment")%>
    <%= Html.ValidationMessage("Comment", "*")%>
  </p>
  <p><input type="submit" value="Submit comment" /></p>
<% } %>

How can the onSuccess Javascript function know whether the result is another version of the form because it didn't validate, a comment as a div to add to the list of comments or a log in page that should be pop up for logging in?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about AJAX