title: Posting JSON with JQuery
body: <p>Trying to get JQuery to post JSON to a server:</p>
  
  <pre><code>$.ajax({  
    url: "/path/to/url",  
    type: "POST",  
    dataType: "json",  
    contentType: "json",  
    data: {"foo": "bar"},  
    success: function(){              
      alert("success :-)");  
    },  
    error: function(){  
      alert("fail :-(");  
    }  
  });  
  </code></pre>
  
  <p>Problem is the data appears on the server as <code>"foo=bar"</code> rather than the desired <code>"{\"foo\":\"bar\"}</code>.</p>
  
  <p>I thought specifying either the dataType or contentType params would do the trick, but no.</p>
  
  <p>Anyone know the correct ajax configuration ? [or alternatively a way of serialising the 'data' parameter as JSON prior to posting ?]</p>
  
  <p>Thanks!</p>