title: How can I update the Database on a checkbox change in MVC
body: <p>I am trying to update my database when a checkbox is checked or unchecked. I want it to update when the checkbox is clicked. This is what I have so far, but my controller is never being hit. what can I do to fix it? Ideally I want to pass in the new value of customer.IsDone and customer.Id to my controller but I don't know how to do this.</p>
  
  <p>Checkbox in my view</p>
  
  <pre><code>    &lt;td&gt;@Html.CheckBoxFor(m =&gt; customer.IsDone, new { onclick = "UpdateCustomer(IsDone)" })&lt;/td&gt;
  </code></pre>
  
  <p>The function in my view</p>
  
  <pre><code>function UpdateCustomer(isDone) {
          $.ajax({
              type: 'POST',
              url: @Url.Action("UpdateCustomer", "Home"),
              data: { check: isDone },
              success: success,
              dataType: 'json'
          });
      }
  </code></pre>
  
  <p>this is my controller method</p>
  
  <pre><code>    [HttpPost]
      public ActionResult UpdateCustomer(bool check)
      {
          //code will be here to update the db
  
          var customers = new CustomerGetAll();
          var list = customers.Execute();
  
          return View("Customers", list);
      }
  </code></pre>