【发布时间】:2013-01-20 23:15:56
【问题描述】:
当我通过node.js 进行 POST 查询时,向Kohana 填充了一些数据,我总是在$this->request->post() 空数组中获取,但是当我通过浏览器本机JavaScript ajax 调用进行查询时 - 它获得正确的数据 - 我已经发送了。
Node.js 代码(我正在使用request 库)- 不工作:
request.post(
'http://someurl',
{ id : 'ididididid' },
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log('returned BODY:', body);
}
}
);
Node.js 正在获取响应 (statusCode == 200) 但它是空数组
jQuery 代码 - 运行良好:
$.ajax({
type: 'POST',
url : 'http://someurl',
dataType : 'JSON',
data : {
id : 'idididid'
},
done : function(data) {
console.log(data.responseText);
}
});
Kohana 代码(控制器内部):
$data = $this->request->post();
echo json_encode($data);
我在这里做错了什么?
【问题讨论】: