How to post the data in Node js

In my application i need to post the dynamic data into my main page(mani page means if i run my url(localhost:3456) in browser means that will display one page na that page).How can i post that data.I have tried this but i couldn't post the data.Can anyone help me to fix the issue.

app.js

     var http = require('http');
     var server = http.createServer(function(req, res){
                  res.writeHead(200, ['Content-Type', 'text/plain']);
                  res.write('Hello ');
                  res.end('World');
                   });
     server.listen(3456);

postdata.js

 var data={"errorMsg":{"errno":34,"code":"ENOENT","path":"missingFile.txt"},"date":"2013-0402T11:50:22.167Z"}
 var options = {
                host: 'localhost',
                port: 3456,
                path: '/',
                method: 'POST',
                data:data,
                header: {
                           'content-type': 'application/json', 
                           'content-length': data.length       
                         }
                 };

 var http=require('http');
 var req;
 req = http.request(options, function(res) {
    var body;
    body = '';
    res.on('data', function(chunk) {
    body += chunk;
  });
 return res.on('end', function() {
    console.log('body is '+body);
  });
  });
 req.on('error', function(err) {
    console.log(err);

});

 req.write(data);
 req.end();

Do you have express installed along with Node, if so you can set up Rest Api's which you can use them in your jQuery and bind data dynamically. Please try to look into http://expressjs.com/

Hope this helps.

Two things. First:

var data={"errorMsg:{"errno":34,"code":"ENOENT","path":"missingFile.txt"},"date":"2013-0402T11:50:22.167Z"}

is missing a double-quote, so it's invalid syntax... hence why the syntax highlighting is having trouble.

Second:

req.write(data);

should be:

req.write(JSON.stringify(data));

EDIT:

Based on your comment, I think you might be asking how to read from the body of an HTTP POST request (you're question is very ambiguously worded). If so, that's already very well documented in the Node.js API. Something along the lines of:

var server = http.createServer(requestHandler);
server.listen(3456);

function requestHandler (req, res) {
    req.setEncoding('utf8');
    var body = '';
    req.on('data', function (chunk) { body += chunk; });
    req.on('end', function () {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('The body of your request was: ' + body);
    });
}

If that's not what you're asking, you'll need to clarify your question. Terms like 'main page' have no meaning unless you explicitly define what they are and what the expected outcome is.

//this is a string
var jsonString = '{"errorMsg":{"errno":34,"code":"ENOENT","path":"missingFile.txt"},"date":"2013-04-03T05:29:15.521Z"}';

//this is an object
var jsonObj = {"errorMsg":{"errno":34,"code":"ENOENT","path":"missingFile.txt"},"date":"2013-04-03T05:29:15.521Z"};

note the single quotes in for string

request.write(chunk, [encoding]) requires chunk to be either Buffer or string (see: http://nodejs.org/api/http.html#http_request_write_chunk_encoding)