title: ASP.NET MVC3 passing one piece of data through a jquery ajax post to an MVC action
body: <p>I'm trying to pass data to an MVC post action that is expecting 1 integer parameter.</p>
  
  <pre><code>[HttpPost]
  public ActionResult DeactivateDepartment(int departmentId)
  {
      return Json(new
          {
              success = _departmentsRepository.ToggleDepartmentState(departmentId, false)
          });
  }
  </code></pre>
  
  <p>The jquery that I'm trying to utilize to hit this action looks like this...</p>
  
  <pre><code>var departmentId = 1;
  $.ajax({
      url: '/Manage/DeactivateDepartment',
      type: 'POST',
      dataType: 'json',
      success: function (data) {
          alert(data);
      },
      data: departmentId
  });
  </code></pre>
  
  <p>When I take the parameter off of the Action method and remove the data attribute from the jquery ajax object I am successfully able to hit the action method.  However, with the action methhod and ajax object as they are shown here I am getting an internal server error.</p>
  
  <p>I've been looking at this post.
  <a href="https://stackoverflow.com/questions/6811625/jquery-ajax-works-to-return-mvc-3-partial-view-but-jquery-load-doesnt">jQuery AJAX works to return mvc 3 partial view but jQuery load doesn&#39;t</a></p>
  
  <p>It shows how to pass a json object that would be deserialized as an object when it hit the action method, but I don't want to have to create a custom class just to receive this one integer value that I'm trying to pass to the method.  How can I configure this thing to just accept the one value?</p>