I am developing API with PHP cake 1.1. I want to write response as JSON. I found a lot of content for PHP Cake 1.2 or 1.3 but not for 1.1.
Here is my controller code
function index() {
$this->layout = 'ajax';
$this->RequestHandler->setContent('json', 'application/json');
$members['id'] = '001100';
$this->set(compact('members'));
}
here is view code
echo json_encode($members);
My problem is that, response content type is still Content-Type: text/html
Is there any way that I do not have to create view for each function and just write json
.
Please help me out.
Thanks, Adil