I have a method that renders xml and it is structured as follows:
/**
* Lista faqs per Flash
*
*/
function xml() {
//$this->autoRender = false;
$this->layout = 'xml/default';
$this->helpers = array('Xml');
$this->RequestHandler->respondAs('xml');
$this->Faq->unbindModel(array('belongsTo' => array('Utente')));
$limit = 10;
$order = "Faq.id DESC";
$conditions = array_merge($this->conditions,
array('Faq.in_homepage'=>1));
$faqs = $this->Faq->findAll($conditions, null, $order, $limit);
$this->set('faqs', $faqs);
}
My xml layout is as follows:
-----------------------------
<?php
$xml->encoding = 'iso-8859-1';
e($xml->header());
?>
<?php echo $content_for_layout; ?>
-----------------------------
This might help as well:
http://www.pagebakers.nl/2007/06/05/using-json-in-cakephp-12/
Dan
On 23 Giu, 12:22, Marcelius <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I have a controller with the RequestHandler component attached, and a
> method called by ajax. Now I want to return pure JSON and to do that I
> need to set the response header content-type to "application/json".
> The problem is that the RequestHandler automaticly sets this response
> header so by the time I get control in my controller, $this-
>
> >RequestHandler->respondAs("json") doesn't have any affect.
>
> What can I do to make this work properly? The dirty hack now is by
> using a header() call in the view but I don't think this is the way to
> do it.
>
> Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---