Added default Ajax action part 2

This commit is contained in:
Anton Terekhov
2011-04-27 19:16:40 +04:00
parent 822e1e614a
commit 01b4bf641b

View File

@ -16,23 +16,21 @@
*/
abstract class AjaxAction extends Action
{
public $template_dir = 'ajax';
public $data = 1;
protected $encode = true;
function __construct()
{
Env::setParam('hide_debug', true);
parent::__construct();
$this->template = 'ajax';
}
function prepare()
function fetch()
{
// header("Content-type: application/json; charset=utf-8");
header("Content-type: text/html; charset=utf-8");
header("Cache-Control: no-store, no-cache, must-revalidate");
$this->templater->assign('data', $this->encode ? json_encode($this->data) : $this->data);
$this->view->assign('data', $this->encode ? json_encode($this->data) : $this->data);
return $this->view->fetch($this->getTemplate());
}
}