request 的一个问题
 发布于 12 年前  作者 liuzhang  4058 次预览  最后一次回复是 12 年前  来自  

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 回复
showen

加上eq.end(); 或者直接用req.end(‘name=liuzhang&age=29’);

liuzhang

已解决了!php $_POST 只能Content-Type:pplication/x-www-form-urlencoded