I'm using CodeIgniter
where I have a driver that returns an array in json format, and I want to receive it from jquery ajax, but I get this error:
Fatal error</b>: Call to undefined function json_encode()
It also turns out that the php version I have on the server is something old, I think it's 5.2 and maybe that's why it does not work.
public function Datos(){
$nrofi = $this->input->post('nrofi');
$data['datos'] = $this->Mimodel->getDatos($nrofi);
echo json_encode($data);
}
var ficha = xx;
$.ajax({
type: 'post',
url: "<?php echo base_url('index.php/MiController/Datos')?>",
data: {nrofi: ficha},
dataType: 'json',
success: function(data){
var d = jQuery.parseJSON(JSON.stringify(data));
console.log(d);
},
error: function(jqXHR, textStatus, errorThrown){
console.log(errorThrown);
}
});
that's my code, in case you can not use json, how can you recover the driver array from ajax ??