Browse Source

Added default Ajax action part 2

master
Anton Terekhov 14 years ago
parent
commit
01b4bf641b
  1. 10
      app/AjaxAction.php

10
app/AjaxAction.php

@ -16,23 +16,21 @@
*/ */
abstract class AjaxAction extends Action abstract class AjaxAction extends Action
{ {
public $template_dir = 'ajax';
public $data = 1; public $data = 1;
protected $encode = true; protected $encode = true;
function __construct() function __construct()
{ {
Env::setParam('hide_debug', true);
parent::__construct(); parent::__construct();
$this->template = 'ajax'; $this->template = 'ajax';
} }
function prepare()
function fetch()
{ {
// header("Content-type: application/json; charset=utf-8");
header("Content-type: text/html; charset=utf-8"); header("Content-type: text/html; charset=utf-8");
header("Cache-Control: no-store, no-cache, must-revalidate"); 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());
} }
} }
Loading…
Cancel
Save