title: Run Controller Method when Button is clicked MVC4 C#
body: <p>I am making a simple application using visual studio 2013, MVC4 and C#. This web app has a table with multiple checkboxes and an Update button disbaled by default. When one or more checkboxes are clicked I activate the button.</p>
  
  <p>The idea here, is to send all the information of the checkboxes (which ones are on or off) to the server when the UPdate button is clicked and then to save those changes in the DB. </p>
  
  <p>To achieve this I am trying to use ajax via jquery, but unfortunatly I am not succeding, because when I click the button nothing happens. </p>
  
  <p>This is the <code>cshtml</code> file that I use to generate the view for the client:</p>
  
  <pre><code>&lt;input type="submit" value="Save Checkbox Changes" class="btn btn-primary disabled" id="SaveCheckboxChanges" /&gt;
  
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.RequiresSetup)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Disabled)
          &lt;/th&gt;
      &lt;/tr&gt;
  
      @{
          foreach (var item in Model)
          {
  
              &lt;tr&gt;
                  &lt;td&gt;
                      @Html.EditorFor(modelItem =&gt; item.RequiresSetup)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.EditorFor(modelItem =&gt; item.Disabled)
                  &lt;/td&gt;
              &lt;/tr&gt;
          }
  }
  &lt;/table&gt;
  </code></pre>
  
  <p>The javascript code that I have for the button <code>SaveCheckboxChanges</code> is the following:</p>
  
  <pre><code>$("#SaveCheckboxChanges").click(function (event) {
          if (!$("#SaveCheckboxChanges").hasClass("disabled")) {
  
              $.ajax({
                  url: '/Material/UpdateCheckBoxes',
                  type: 'POST',
                  data: {bla: "bdsjdnjsdnsnd"
  
                  },
                  contentType: 'application/json; charset=utf-8',
                  success: function (data) {
                      alert(data.success);
                  },
                  error: function () {
                      alert("error");
                  }
              });
          }
  
      });
  </code></pre>
  
  <p>And in my materials controller, I have the following:</p>
  
  <pre><code>[HttpPost]
  public ActionResult UpdateCheckBoxes(string bla)
  {
      return Content("Working!" +  bla);
  }
  </code></pre>
  
  <p>What I expect, is that after clicking the button, the page shows the "Working" string, meaning that the function in the controller was executed correctly. </p>
  
  <p>However, this is not happening, and all I see is the javascript alert saying "error". </p>
  
  <p>How can I make this ajax request work? What am I missing?</p>