title: MVC Ajax.Beginform OnComplete/OnSuccess fired before controller call
body: <p>I'm trying to clear an ajax form after an item has been added to the database however the OnComplete and OnSuccess AjaxOptions get called before the form is submitted. How can I get it so the form is submitted first and the the OnComplete is called.</p>
  
  <pre><code>&lt;% using (Ajax.BeginForm("AddTable", new AjaxOptions
                                          {
                                              UpdateTargetId = "tables",
                                              InsertionMode = InsertionMode.InsertAfter,
                                              OnComplete = "ClearForm()"
                                          }))
     {%&gt;
  </code></pre>
  
  <p>which calls</p>
  
  <pre><code>function ClearForm() {
          $('#DisplayName').val('');
      }
  </code></pre>
  
  <p>However the DisplayName textbox is cleared before the balue is sent to the controller the form submits to. Is there a way around this.</p>