Skip to content

Instantly share code, notes, and snippets.

@Zifius
Created July 9, 2011 13:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zifius/1073576 to your computer and use it in GitHub Desktop.
Save Zifius/1073576 to your computer and use it in GitHub Desktop.
Ajax controller with JSON response for Kohana 3.1
<?php
class Controller_Ajax extends Controller {
public function before()
{
if (!$this->request->is_ajax())
{
$this->request->redirect();
}
$this->response->headers('Content-Type', 'application/json; charset=utf-8');
}
public function action_data()
{
$this->response->body(json_encode(array('test'=>'json'));
}
}
@batman33
Copy link

good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment