title: How to return success from ajax post in Node.js
body: <p>I have a function like this:</p>
  
  <pre><code>exports.saveAction = function (req, res) {
      var conn = mysql.createConnection({
          host     : nconf.get("database:host"),
          //port: 3306,
          user     : nconf.get("database:username"),
          password : nconf.get("database:password"),
          database : nconf.get("database:database"),
          multipleStatements: true,
          //ssl: 'Amazon RDS'
      });
      var action = req.body;   
      conn.query('UPDATE actions SET ? WHERE Id = ?', 
                    [action, action.Id], function (err, result) {
          conn.end();
          if (err) throw err;
          res.writeHead(200, { "Content-Type": "application/json" });
          res.end("Updated Successfully");
      });
  };
  </code></pre>
  
  <p>and I am return "200", but it always returns in the error clause shown below:</p>
  
  <pre><code>$.ajax({
      url: "/api/action/SaveAction",
      type: "PUT",
      data: ko.toJSON(self.stripDownObj()),
      datatype: "json",
      contentType: "application/json; charset=utf-8",
      success: function (result) {
          console.log(result);
          if(result.status == 200){
              self.isEditMode(!self.isEditMode());
          }
      },
      error: function(result){
          console.log(result);
      }
  });
  </code></pre>
  
  <p>Note: the sql query is successful and does save the data.</p>