I have a controller that extends the base controller. It already implements several non-restful actions. I'd like to add a method to this controller that is intended to return RESTful responses. So far, it does not seem to be working - using Chrome's network console, it appears that the controller is attempting to send back an entire template. How can I prevent this from happening?
Here is my code - note that it is just a shim so far for testing:
public function action_submit()
{
$this->response->set_header('Content-Type', 'application/json');
$this->response->body(json_encode(array('success' => TRUE)));
}
How can I actually force it to return just this, without the template?
EDIT: I'd just like to add that, if possible, I'd prefer to avoid creating a new controller that extends the restful controller. I just need this one, simple method, and it makes the most sense in the context of my existing controller. I'll create a new one that extends the restful controller if I absolutely have to, but I would really prefer to avoid it.