Showing posts with label json. Show all posts
Showing posts with label json. Show all posts

Wednesday, August 4, 2010

JSON Response in Symfony

If you want an action returns with json data, create something like this:
public function executeJson(sfWebRequest $request)
{
   $this->getResponse()->setContentType('application/json');
   // create the data
   $data = "something";
   return $this->renderText(json_encode($data));
}