title: Post jQuery JSON Object to NodeJs Restify
body: <p>I want to know why it is so hard to post a simple JSON string in a <code>/:parameter</code> to restify. I have followed many examples but have not found anything concrete.</p>
  
  <p>I have the following code in the front end.</p>
  
  <pre><code>$("#btnDoTest").click(function() {
  
      var jData = {
          hello: "world"
      };
      var request = $.ajax({
          url: "http://localhost:8081/j/",
          async: false,
          type: "POST",
          data: JSON.stringify(jData),
          contentType: "application/javascript",
          dataType: "json"
      });
  
  
      request.success(function(result) {
  
          console.log(result);
  
      });
  
      request.fail(function(jqXHR, textStatus) {
          alert("Request failed: " + textStatus);
      });
  
  
  });
  </code></pre>
  
  <p>I am succesful in sending simple text if I concatenate the param after the <code>j/</code>. But what I want to send is an object like this <code>{hello:"world"}</code> and reconstruct it back in nodeJS and work with it.</p>
  
  <p>--Edit:</p>
  
  <pre><code>This is my nodejs file
  /* the below function is from restifylib/response.js */
  var restify = require("restify");
  
  /* create the restify server */
  var server = restify.createServer({
  
  });
  
  
  server.use(restify.bodyParser({ mapParams: true }));
  
  server.use(
    function crossOrigin(req,res,next){
      res.header("Access-Control-Allow-Origin", "*");
      res.header("Access-Control-Allow-Headers", "X-Requested-With");
      return next();
    }
  );
  
  
   server.post('/j/', function (req, res, next) {
  
  
     //res.send(201,"REceived body: "+JSON.stringify(req.params));
     res.send(201,"REceived body: "+JSON.stringify(req.params));
     return next();
   });
  
  
  var port = 8081;
  server.listen(port);
  console.log("Server listening on port " +port)
  </code></pre>
  
  <p>Any help would be appreciated thanks.</p>
  
  <p>0x</p>