[eluser]Unknown[/eluser]
hello guys.. when I try to get a json response, it comes wrapped in <html><head>, etc tags... how can I do that?
I've already set
Code:
$this->output->set_header('Content-Type: application/json; charset=utf-8');
$this->output->set_output( $this->object->allToJSON());
but that's the response:
Code:
<html>
<head>
</head>
<body>
[{"id_sindrome":"234","descricao":"1P36 DELETION SYNDROME ","diag_sindromes":[],"sindrome_imagem":[],"sindrome_texts":[],"sindromes_sinais":[]},{"id_sindrome":"218","descricao":"22Q13 DELETION SYNDROME ","diag_sindromes":[],"sindrome_imagem":[],"sindrome_texts":[],"sindromes_sinais":[]},{"id_sindrome":"96","descricao":"3-M SYNDROME ","diag_sindromes":[],"sindrome_imagem":[],"sindrome_texts":[],"sindromes_sinais":[]},{"id_sindrome":"254","descricao":"3CSYNDROME","diag_sindromes":[],"sindrome_imagem":[],"sindrome_texts":[],"sindromes_sinais":[]},{"id_sindrome":"76","descricao":"45X SYNDROME (XO SYNDROME TURNER SYNDROME) ","diag_sindromes":[],"sindrome_imagem":[],"sindrome_texts":[],"sindromes_sinais":[]}]
<div id="errors">
</div>
<div id="messages">
</div>
</body>
</html>
and this is the index method:
Code:
public function index() {
$this->sort = "descricao";
$this->limitless = false;
parent::load();
switch ($this->format) {
case "js" :
case "json" :
//header('Content-Type: application/json; charset=utf-8');
$this->output->set_header('Content-Type: application/json; charset=utf-8');
$this->output->set_output( $this->object->allToJSON());
return true;
break;
case "xml" :
header('Content-Type: application/xml; charset=utf-8;');
$this->output->set_header('Content-Type: application/xml; charset=utf-8');
$this->output->set_output( $this->object->allToXML());
break;
default :
header('Content-Type: text/html; charset=utf-8');
$this->data["objects"] = $this->object->allToObject();
$this->data["title"] = "Syndromes";
$this->load->view("syndrome/index",$this->data);
break;
}
}
some tips?
tks