The Node.js equivalent to that code can be using jQuery server-side, using other modules, or using the native HTTP/HTTPS modules. This is how a POST request is done:
var http = require('http');
var data = JSON.stringify({
'id': '2'
});
var options = {
host: 'host.com',
port: '80',
path: '/WebServiceUtility.aspx/CustomOrderService',
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Content-Length': data.length
}
};
var req = http.request(options, function(res) {
var msg = '';
res.setEncoding('utf8');
res.on('data', function(chunk) {
msg += chunk;
});
res.on('end', function() {
console.log(JSON.parse(msg));
});
});
req.write(data);
req.end();
This example creates the data payload, which is JSON. It then sets up the HTTP post options, such as host, port, path, headers, etc. The request itself is then set up, which we collect the response for parsing. Then we write the POST data to the request itself, and end the request.