Created
July 9, 2011 13:13
-
-
Save Zifius/1073576 to your computer and use it in GitHub Desktop.
Ajax controller with JSON response for Kohana 3.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good!