【发布时间】:2017-06-15 22:27:18
【问题描述】:
角度代码:
sendData(obj){
const userObj = JSON.stringify(obj); console.log(userObj);
let headers = new Headers();
headers.append("Content Type","application/json");
return this.http.post('http://localhost/codeigniter/index.php/ngGet_Controller/posted', userObj, headers);
}
CoeIgniter(控制器)代码:
public function posted(){
$postdata = file_get_contents("php://input");
var_dump(json_decode($postdata));
print_r($this->input->post());
}
【问题讨论】:
-
我尝试了答案,但我没有得到我的代码有什么问题,我仍然在 codeIgniter 方面得到空值,我是否需要在我的 codeIgniter 中配置一些东西?由于角度响应很好。
-
请您也发布“userObj”。
-
我的 userObj 给了我这个:- ({"username1":"test","email1":"test@test.com"})
-
有人请帮忙!
标签: angular codeigniter