title: Reading data from res.end()
body: <p>I'm sending a simple data back from the server to the client.</p>
  
  <pre><code>app.post('/user', function (req, res) { 
      var userName = "John";
      res.end(JSON.stringify({"error":"", "user": userName}));
  });
  
  
  $.ajax({
      type: "POST",
      ...
      contentType : 'application/json',
      dataType: "json"
  })
      .done(function(data) {
          // send join message
          var resData = JSON.parse(data);
          alert("hello"); // this doesn't show up
          });
      });
  });
  </code></pre>
  
  <p>But in the browser console, I get this error - "Uncaught SyntaxError: Unexpected token o". </p>
  
  <p>If I do <code>JSON.stringify</code> and <code>JSON.parse</code> on the content, it works fine.</p>
  
  <pre><code>alert(JSON.parse (JSON.stringify({"error":"", "user": userName})).user); 
  </code></pre>
  
  <p>And also, <code>.done</code> works fine without a data payload from the server i.e. the <code>alert("hello")</code> works.</p>
  
  <p>So, I'm guessing something fishy is happening while sending data within <code>res.end()</code>. Please help.</p>
  
  <p>While at it, it would be nice if you can also tell me how to do the same using res.json() and which one is preferable.</p>