当我尝试在浏览器中加载表单数据时,它会显示此错误
{“”:“未知方法”} 如何解决
这是Restapi中使用Codeigniter的控制器代码。
帮助我摆脱这个问题.......
require(APPPATH.'/libraries/REST_Controller.php');
class Api extends REST_Controller{
public function __construct()
{
parent::__construct();
// $this->CI->lang->load('form_validation');
$this->load->model('book_model');
$this->load->helper('url');
}
public function view_get(){
$this->load->helper('form');
}
public function display_post(){
$this->load->helper('form');
$this->load->view('add');
}
}
Add.php代码在这里,我想通过控制器在网页中显示数据,但是当我运行此代码时显示错误
{“”:“未知方法”}
网址: http://localhost/code-restfullAPI/index.php/API/display
<!DOCTYPE html>
<html>
<body>
<form method="POST" action="<?php site_url('index.php/Api/addBook_post'); ?>">
Name:<br>
<input type="text" name="name" >
<br>
Price:<br>
<input type="text" name="price" >
<br>
Author:<br>
<input type="text" name="author" >
<br>
Category:<br>
<input type="text" name="category" >
<br>
Language:<br>
<input type="text" name="language" >
<br>
ISBN:<br>
<input type="text" name="isbn" >
<br>
Publish Date:<br>
<input type="text" name="publish_date" >
<br>
<input type="submit" value="Add">
</form>
</body>
</html
答案 0 :(得分:0)
SITE_URL( '的index.php /原料药/ addBook_post');
从addBook_post
中删除“_post”