title: Submit a Form via AJAX and Return a Partial View - MVC2
body: <p>Seems like there are a lot of ways to solve this problem.</p>
  
  <p>Currently I make a partial view with a form like so:</p>
  
  <pre><code>&lt;div id="container"&gt;
      &lt;form id="some-form"&gt;
          &lt;input id="some-text" type="text"&gt;
          &lt;input id="some-submit" type="submit"&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>then I hijack the submit with JQuery and do an ajax post and replace the form with another partial view:</p>
  
  <pre><code>$(function()
  {
      $('#some-form').submit(function(){
            $.ajax({
                 type: "POST",
                 url: "/Controller/Action",
                 data: {someVal: $('#some-text').val()},
                 dataType: "html",
                 success: function (result) {
                     $('#container').html(result);
                 },
                 error: function (request, status, error) {
                     alert('Oh no!');
                 }
           });
      });
  });
  </code></pre>
  
  <p>The controller would be like:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult SomeAction(string someVal)
      {
          //Do something with text
          return PartialView("SubmitSuccess");
      }
  </code></pre>
  
  <h2>My Question</h2>
  
  <p>What are other ways to accomplish the same thing and what are the pros and cons vs what I am doing?</p>
  
  <p>Is Ajax.Form useful?</p>