I have built few rest API on server and calling them from other domain the Get request is working fine but I am facing an issue in calling the POST request.
I am unable to receive data on server send by the clients.
Server Code:
var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
//var fn = require('fn')
var app = express();
var allowCrossDomain = function(req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');
    // intercept OPTIONS method
    if ('OPTIONS' === req.method) {
        res.send(200);
    }
    else {
        next();
    }
};
// all environments
app.set('port', process.env.PORT || 3000);
app.use(allowCrossDomain);
// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}
app.post('/user', user.saveUser);
http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});
exports.saveUser = function(req, res) {
    var key = req.body.key; //fb,twitter,web
    var userData = req.body.userData;
    var result  = checkUser(userData,key);        
}
Clients code where the request is made :
var data = { key: 'web', userData: userData }
$.ajax({
    method: "POST",
    //contentType: 'application/json',
    url: "www.acbd.com/user",
    //url:"http://prayable-21641.onmodulus.net/user",
    data: data,
    crossDomain: true,
    dataType: "json"
}).success(function (data, textstatus) {
    // this callback will be called asynchronously
    // when the response is available
    console.log(data)
    console.log(textstatus)
}).error(function (data, textstatus) {
    console.log(data)
    console.log(textstatus)
    // called asynchronously if an error occurs
    // or server returns response with an error status.
});
I am unable to get key or userData on server, it say they are not defined:
TypeError: Cannot read property 'key' of undefined
 
     
     
     
    