gpt4 book ai didi

php - 在 codeigniter Controller 中获取整个帖子主体

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:04:05 24 4
gpt4 key购买 nike

我正在像这样运行 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 Controller 的 ipsum 函数中的 JSON 数据。我怎样才能做到这一点? $this->input->post(); 返回 false :(

最佳答案

使用file_get_contents('php://input')

关于php - 在 codeigniter Controller 中获取整个帖子主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4339616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com