title: Translate MVC Ajax.ActionLink to jQuery .post method?
body: <p>I am dealing with this ASP.NET MVC problem of that using ValidateAntiForgeryToken with AJAX breaks the AJAX call (<a href="https://stackoverflow.com/questions/1786500/using-validateantiforgerytoken-with-ajax-actionlink">Using ValidateAntiForgeryToken with Ajax.ActionLink</a>). The only solution (as stated in that topic) requires jQuery.</p>
  
  <p>How do i do the eqvivalent of the following with jQuery's .post method?</p>
  
  <pre><code>@Ajax.ActionLink("Perform HTTPPost", "PostTest", new AjaxOptions{ HttpMethod="POST"})
  </code></pre>
  
  <p>Here is the Controller:</p>
  
  <pre><code>// [ValidateAntiForgeryToken]
  public class MoreInfoController : Controller
  {        
      [HttpPost]
      public ActionResult PostTest()
      {
          return View();
      }
  }
  </code></pre>
  
  <p>Here is it's Index VIEW with both Javascript and HTML:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $('#linkToPost').click(PostForm);
      });
  
      function PostForm() {
          $.post("/PostTest", $('#testForm').serialize(), function(data) {
  
          });
          return false;
      }
  
  &lt;/script&gt;
  &lt;a id="linkToPost" href="#"&gt;Perform HTTP Post&lt;/a&gt;
  &lt;form id="testForm" method="POST" &gt;
      @Html.AntiForgeryToken()
  &lt;/form&gt;
  </code></pre>
  
  <p>And here is the Route:</p>
  
  <pre><code>routes.MapRoute("PostTest1",
                              "PostTest",
                              new {controller = "MoreInfo", action = "PostTest"}
          );
  </code></pre>