Codeigniter REST API帖子无效

require APPPATH.'libraries/REST_Controller.php';

class Test extends REST_Controller {

function ajax_all_webinars_get() {
    $this->response(array("success"=>"get"), 200);
}

function list_post() {
    $this->response(array("success"=>"post"), 200);
}
}

In the browser I can make a call to ajax_all_webinars via a javascript ajax call to retrieve all the webinars and get a 200 OK.

However when I even try to post to the post function I get a 404.

can anyone help please.

call to the service

$.ajax({
type: "post",
url: "http://corss-domain-server/test/list/",
crossDomain: true,
data: postData,
//dataType: "json",
success: function(responseData, textStatus, jqXHR) {
    console.log(responseData)
},
error: function(jqXHR, textStatus, errorThrown) {
    console.log(jqXHR);
}
})

The main reason that codeigniter doesn't recognize the post data in REST Api is not setting content-type.

So Set the content-type in Ajax Call and check.

You can add the below line to the ajax call,if below line not works then try any other content type.

contentType: "application/x-www-form-urlencoded"