Skip to content

Instantly share code, notes, and snippets.

@nikhgupta
Created March 22, 2012 19:50
Show Gist options
  • Save nikhgupta/2162850 to your computer and use it in GitHub Desktop.
Save nikhgupta/2162850 to your computer and use it in GitHub Desktop.
Render as JSONP inside CakePHP
public function someController()
{
// $callback is retrieved from the params
$message = "some message";
$this->autoRender = false;
$this->RequestHandler->respondAs('json');
if ($cb) echo $callback."(".json_encode(array("message" => $message)).");";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment