Reputation: 1764
cakephp debug messages still displaying with debug set to 0 using ajax and json. I cannot set autorender to false, as I need to set the header to send json.
json.ctp
<?php
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
header('Content-Type: application/json');
header("X-JSON: ".$json);
echo $json;
?>
Controller
function index(){
if (!empty($this->data)){
// Handle all JSON requests here
if ($this->RequestHandler->isAjax()){
$domain = $this->data['domain'];
$results = $this->Domain->google_api($domain,$seo_action);
$json = json_encode($results);
$this->set(compact('json'));
$this->render('json','ajax');
} else {
$domain = $this->data['Results']['domain'];
}
}
$this->set(compact('domain'));
$this->layout = 'front_end';
}
app_controller
function beforeFilter(){
if ($this->RequestHandler->isAjax()) Configure::write('debug', 0);
}
Upvotes: 0
Views: 296
Reputation: 87073
You can put the Configure::write('debug', 0);
as first line to your json.ctp
. so that it will:
<?php
Configure::write('debug', 0);
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
header('Content-Type: application/json');
header("X-JSON: ".$json);
echo $json;
?>
Upvotes: 1