title: asp.net mvc 3 - ajax form submit and validation
body: <p>I am sorry if this has been asked already, but I have been looking for sometime but all I have found are rather old posts (mvc1, mvc2).
  I have a form which I would like to submit via Ajax.</p>
  
  <p><a href="https://stackoverflow.com/questions/298691/asp-net-mvc-ajax-form-with-jquery-validation">This</a> looks like it would work but does not cover server side validation.</p>
  
  <p>1) I am unsure if I should use the <code>AjaxHelper.BeginForm</code> or use raw jquery calls <code>($.ajax)</code>? What is the recommended approach here?</p>
  
  <p>2) How do I handle client and server side validation? I am hoping the mvc framework provides a built in mechanism for dealing with this?
  There are some validations which I am only doing server side. Would using a <code>ValidationSummary</code> still work here?</p>
  
  <p>I am using asp.net mvc3/razor with unobtrussive javascript validation.</p>
  
  <p>Thank you!</p>
  
  <p><strong>Edit: (as requested by Bobby B below).</strong>
  This was added months after asking the question as a user wanted to know how to use AjaxHelper</p>
  
  <p>This is the javascript code I used:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function ajaxValidate() {
    return $('form').validate().form();
  }
  
  function getGbPostSuccess(ajaxContext){
    // .... it is not necessary to do anything here.
  }
  function showFaliure(ajaxContext){
     // handle failure
  }
  </code></pre>
  
  <p></p>
  
  <p>HTML snippet:</p>
  
  <p>
      </p>
  
  <pre><code>@using (Ajax.BeginForm("Index", "Home", new AjaxOptions
                          {
                              UpdateTargetId = "form1",
                              InsertionMode = InsertionMode.Replace,
                              OnBegin = "ajaxValidate",
                              OnSuccess = "getGbPostSuccess",
                              OnFailure = "showFaliure"
                          }))
  {
  </code></pre>