title: Sending a JSON POST request via AJAX
body: <p>I'm using POST to submit data to the server, this error appears in the console:</p>
  
  <blockquote>
    <p>POST localhost/myProject/webapp/setAccount 400 (Required String parameter 'accountID' is not present) </p>
  </blockquote>
  
  <p>The user will select from a combo box an account ID and this is what should be passed in the post.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>accountSelected: function () {
  
   var accountSelected = $("#accountcombobox").val();
   console.log("Selected Account: " + accountSelected);
       var myUrl = "webapp/setAccount";
  
       $.ajax({
           url: myUrl,
           type: "POST",
           data: accountSelected,
           dataType: "json",
           contentType: "application/json"
              })
           .done(function (data) {
           console.log("Response " + JSON.stringify(data));
           })
          }
  </code></pre>
  
  <p>The first console.log shows the selected account ID as expected so i know the value is correct.  I want to pass this value to the POST request, which is what i thought i was doing but cannot seem to get it to work.</p>
  
  <p>EDIT</p>
  
  <p>Thanks for the responses but none of the answers seem to be working for me, still the same error.</p>
  
  <p>I'm also using Marionette and Backbone, could this effect it?</p>