title: what is wrong with my jQuery POST request?
body: <p>I am trying to authenticate with a remote service through jQuery.  First, I verify that I can do this outside of the browser:</p>
  
  <pre><code> curl -X POST -H "Content-Type: application/json" -H "Accept: appliction/json" -d '{"username":"...","password":"..."}' http://example.com/auth
  </code></pre>
  
  <p>This successfully returns a token.</p>
  
  <p>Now I try it with jQuery:</p>
  
  <pre><code>$.ajax({
      url: "http://example.com/auth",
      type: "POST",
      dataType: "json",
      contentType: "json",
      data: {username:"...",password:"..."},
      error: function(data){alert(JSON.stringify(data))},
      success: function(data){alert(JSON.stringify(data))}
  });
  </code></pre>
  
  <p>I get a server error (500).  Clearly I am doing something wrong.  This is my first time trying to do a POST in jQuery, so I don't know how to identify what the problem is.  What am I doing wrong here?</p>
  
  <p>P.S. I can successfully do a GET request through jQuery, if I already have a token:</p>
  
  <pre><code>$.ajax({
      url: "http://example.com/stuff?token=f42652adcbfe3ed9d59fae62b5267b8d",
      type: "GET",
      dataType: "json",
      error: function(data){alert(JSON.stringify(data))},
      success: function(data){alert(JSON.stringify(data))}
  });
  </code></pre>