title: How do I convert an object to an ajax body in jQuery?
body: <p>I have an <code>express</code> server that is expecting a user object.  I am submitting the <code>ajax</code> request to the server via an <code>jQuery ajax</code> call.  Here is my client side code:</p>
  
  <pre><code>var user = {
      "first_name": "Jimi",
      "last_name": "Hendrix",
      "email": "jimi@gmail.com"
  };
  $.ajax({
      type: 'POST',
      url: 'http://localhost:9000/stuff',
      dataType: 'json',
      data: {user: user}
  });
  </code></pre>
  
  <p>The body never makes it to <code>express</code>.  Here is my <code>express</code> setup.  </p>
  
  <pre><code>var app = express();
  app.use(bodyParser.json());
  
  if (req.method === 'OPTIONS') {
      res.send(200);
    } else {
      next();
    }
  }
  
  app.post('/stuff', function(req, res) {
      'use strict';
      console.log(req.body);
      res.send(200);
  });
  </code></pre>
  
  <p>My <code>console.log(req.body)</code> always returns the same thing, 
  <code>body: {}</code></p>
  
  <p>What do I need to do for my body to make it across to my server?  Do I need to serialize the data?  I thought I could just attach the object.</p>