【发布时间】:2018-02-03 02:52:17
【问题描述】:
我花了一整天的时间试图找出这个问题。在这里发布这个问题是我最后的希望。我希望有人可以帮助我继续从事我的第一份工作。
SyntaxError:JSON.parse:JSON 数据的第 2 行第 1 列出现意外字符
所以,当直接将数据从我的视图直接传递到 RestServer 时,POST 可以正常工作。但是,RESTServer API 无法找到从 RestClient 发送的 POST 数据。
我的例子
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH . 'libraries/REST_Controller.php';
class Example extends REST_Controller {
function __construct()
{
parent::__construct();
$this->methods['get']['limit'] = 500;
$this->methods['post']['limit'] = 200;
$this->methods['delete']['limit'] = 50;
}
public function post()
{
$message = array(
'id' => null,
'name' => $this->input->post('name'),
'message' => $this->input->post('email')
);
$this->set_response($message);
}
}
【问题讨论】:
-
尝试使用不同的名称,例如
index_post()。 Docs. -
我们可以更改但显示以下错误
-
status false 错误“未知方法”