symfony-users  

[symfony-users] debugging json apps

Lukas Kahwe Smith
Mon, 06 Aug 2007 05:33:21 -0700

Hi,

I am writing a JSON heavy application. In order to be able to debug JSON
replies more easily, I created a dedicated method for this purpose. The
idea is that when in debug mode and the request is not a proper AJAX
(err AJAJ) request, it would enable a json.php layout template and place
the print_r() output of the data structure inside the json.php layout
template:

   public function returnJSON($data)
   {
     if(SF_DEBUG && !$this->getRequest()->isXmlHttpRequest()) {
       $json = "<pre>\n".print_r($data, true);
       $this->setLayout('json');
       return $this->renderText($json);
     }

     $json = json_encode($data);
     $this->getResponse()->setHttpHeader("X-JSON", '('.$json.')');
     return sfView::HEADER_ONLY;
   }

However it does not seem to be enabling the json layout template.
Probably an obvious stupid mistake .. does renderText() aka sfView::NONE 
preclude the use of a layout template? If so how else can I not load an 
action template but still be able to pass some text from the action to 
the layout directly?

regards,
Lukas


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---