Php codeigniter和ionic应用程序中RESTful api中的post请求存在问题
在我的codeigniter项目中,我有REST_控制器创建的api,我们有ionic应用程序,它通过angular连接到api。当应用程序发送get请求时,api正常工作。但当应用程序发送post请求时,我们有405错误(不允许使用405方法) 这是我的错误: 这是我的控制器: 我尝试配置php头,但api不工作Php codeigniter和ionic应用程序中RESTful api中的post请求存在问题,php,apache,rest,codeigniter,http,Php,Apache,Rest,Codeigniter,Http,在我的codeigniter项目中,我有REST_控制器创建的api,我们有ionic应用程序,它通过angular连接到api。当应用程序发送get请求时,api正常工作。但当应用程序发送post请求时,我们有405错误(不允许使用405方法) 这是我的错误: 这是我的控制器: 我尝试配置php头,但api不工作 use Restserver\Libraries\REST_Controller; require(APPPATH.'/libraries/REST_Controller.php'
use Restserver\Libraries\REST_Controller;
require(APPPATH.'/libraries/REST_Controller.php');
require(APPPATH.'/libraries/REST_Controller_Definitions.php');
require(APPPATH.'/libraries/Format.php');
class Mobile_api extends REST_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Flights_model');
}
public function search_post(){
$from = $this->post('from');
$to = $this->post('to');
$date = $this->post('date');
$adult = $this->post('adult');
$child = $this->post('child');
$infant = $this->post('infant');
$type = $this->post('type');
if(!$from || !$to || !$date || !$adult || !$type){
$this->response("Enter complete search information", 400);
}else{
$this->session->set_userdata("adult", $adult);
$this->session->set_userdata("child", $child);
$this->session->set_userdata("infant", $infant);
$token = rand(1000,9999).time();
$result = array();
$counter = 0;
$result = $this->Flights_model->get_result($from, $to, $date, $token, NULL, NULL, NULL, NULL, NULL);
if($result){
$this->response($result, 200);
exit;
}
else{
$this->response("Invalid ISBN", 404);
exit;
}
}
}
}
不要链接到错误消息的图像。编辑问题以将错误消息添加为文本。这是错误:请求方法E:选项,状态代码:405不允许使用方法