title: Data is not sent from view (ajax) to controller (c#)
body: <p>I'm new to AJAX, and I don't understand, why my data was not sent to controller.
  So, on my View I have two input forms and a button:</p>
  <h2>HTML:</h2>
  <pre><code>&lt;input type=&quot;text&quot; name=&quot;AddName&quot;&gt;
  &lt;input type=&quot;text&quot; name=&quot;AddEmail&quot;&gt; 
  &lt;button class=&quot;btn btn-mini btn-primary&quot; type=&quot;button&quot; name=&quot;add_btn&quot; onclick=&quot;DbAdd()&quot;&gt;Add&lt;/button&gt;
  </code></pre>
  <p>I need after button &quot;add_btn&quot; clicked take data from these two inputs and send them to controller.</p>
  <h2>JavaScript:</h2>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
      function DbAdd()
      {
          // Get some values from elements on the page:
          var $form = $(this),
              addedName = $form.find(&quot;input[name='AddName']&quot;).val(),
              addedEmail = $form.find(&quot;input[name='AddEmail']&quot;).val();
  
          $(&quot;#UserTable&quot;).html(&quot;&lt;div&gt;Please Wait...&lt;/div&gt;&quot;);
          $.ajax(
          {
              type: &quot;POST&quot;,
              url: &quot;Save&quot;,
              data:
                  {
                      name: addedName, email: addedEmail,
                  },
              dataType: &quot;json&quot;,
              contentType: &quot;application/json; charset=utf-8&quot;,
              success: OnSuccess,
              error: OnError
          });
  }
  </code></pre>
  
  <p>And this is my controller's method &quot;Save&quot; (I need to save data got from ajax to my DB):</p>
  <pre><code>[HttpPost]
  public ActionResult Save(User userinfo)
  {
      string message = &quot;&quot;;
  
      using (var uc = new UserContext())
      {
          uc.UserList.Add(userinfo);
          uc.SaveChanges();
          message = &quot;Successfully Saved!&quot;;
      }
      
      if (Request.IsAjaxRequest())
      {
          return new JsonResult { Data = message };
      }
      else
      {
          ViewBag.Message = message;
          return View(userinfo);
      }
  } 
  </code></pre>
  <p>The problem is that when I put a break point to my controller's method, I don't receive data from ajax, null's only. So I add an empty record to DB.
  Any suggestions?</p>