【发布时间】:2010-12-02 20:39:26
【问题描述】:
我正在运行 XMLHttpRequest 这样的请求:
var data = JSON.stringify({
name : "123",
id : 12
});
window.console.log("Submitting: " + data);
var req = new XMLHttpRequest();
req.open('POST', "http://localhost/index.php/lorem/ipsum", true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.onreadystatechange = function() {
if ( req.readyState==4) {
window.console.log( "Sent back: " + req.responseText );
}
}
req.send(data);
如您所见,传递的参数没有名称。
现在我想读取 lorem 控制器的 ipsum 函数中的 JSON 数据。
我怎样才能做到这一点? $this->input->post(); 返回 false :(
【问题讨论】:
-
我认为我来晚了,但内容类型应该是 application/json(是的,我知道它不会有任何影响)
标签: php ajax codeigniter