title: Is it OK for an Controller Action to return void with a jQuery post?
body: <p>The reason I ask this question is because I don't see too many examples of it.  Basically, I have a <code>controller</code> which has an <code>method that returns void</code>.  The method is called by a <code>post</code> which is done through <code>jQuery</code>.  If the post is successful, I just update a small part of the page with some html.  I do not need anything back from the method, so it is fine and acceptable that I return void?  If not, what do you usually return from controller methods when making ajax calls?</p>
  
  <p>Here is my Controller method:</p>
  
  <pre><code>[HttpPost]
  public void AddToCart(ShoppingCartItem shoppingCartItem)
  { 
  
  _shoppingCartService.AddItem(shoppingCartUserId, shoppingCartItem);
  
  }
  </code></pre>
  
  <p>Here is my javascript:</p>
  
  <pre><code>$(function () {
  $("#addToCart").submit(function (e) {
  
      e.preventDefault();
  
      var shoppingCartItem = JSON.stringify(
      {
          'Name': $('#Name').val(),
          'ProductId': $('#ProductId').val(),
          'ShortDescription': $('#ShortDescription').val(),
          'Sku': $('#Sku').val()
      });
  
      AddToCart(shoppingCartItem);
  });
  
  function AddToCart(shoppingCartItem) {
      $.ajax({
          url: '/ShoppingCart/AddToCart',
          async: false,
          type: "POST",
          data: shoppingCartItem,
          dataType: "html",
          contentType: "application/json",
          error: function (data) {
              console.log(data);
          },
          success: function () {
  
              var count = parseInt($('div.item-counter').html()) + 1;
              $('div.item-counter').html(count);
  
          }
      });
  }
  </code></pre>
  
  <p>}());</p>
  
  <p>I noticed that if I my action method fails, the error function will be called and if it succeeds to success function will be called.</p>