【发布时间】:2013-09-27 12:24:18
【问题描述】:
我正在使用主干和 CodeIgniter Rest Server, 来自主干的帖子和获取请求工作正常 但是 put 和 delete 请求者得到 404 错误,响应为 {"status":false,"error":"Unknown method."}
编辑:我更改了源代码以查看 codeigniter 尝试运行的方法 我的控制器网址是
http://local/host/impacto/index.php/interviews/
put 请求的 url 是
http://localhost/impacto/index.php/interviews/13
codeigniter 运行的函数是 13_put 而不是 input_put
我的控制器
class Interview extends REST_Controller {
function __construct(){
parent:: __construct();
}
public function index_get(){
echo "get";
}
public function index_post(){
echo "post";
}
public function index_put($id){
echo "update: " . $id;
}
public function index_delete($id){
echo "delete: " . $id;
}
}
【问题讨论】:
-
我遇到了完全相同的问题;向“Interview/{id}”发送 PUT 调用方法“13_put()”而不是“index_put(13)”,如您所料...
标签: php codeigniter rest backbone.js