request 的一个问题
var options = { host: ‘localhost’, port: 80, path: ‘/backbone/data.php’, method: ‘POST’ };
var req = http.request(options, function(res) { console.log('STATUS: ’ + res.statusCode); console.log('HEADERS: ’ + JSON.stringify(res.headers)); res.setEncoding(‘utf8’); res.on(‘data’, function (chunk) { console.log('BODY: ’ + chunk); }); }); // write data to request body req.write(‘name=liuzhang&age=29’);
为什么用$_POST是空的,我已经res.write
2 回复
加上eq.end(); 或者直接用req.end(‘name=liuzhang&age=29’);
已解决了!php $_POST 只能Content-Type:pplication/x-www-form-urlencoded