I have a script that basically check if there is a result from a query:
$.post('<?php echo site_url('xxx/yyy'); ?>',{data:no},function(result){
if(!result){
alert("No Data");
}
else{
alert("Data retrieved");
}
});
Why my IF
alert Data retrieved
when I get empty JSON array. I tried to do alert(result)
with different data (the data which result is empty and result is true), but both data is alerting Data retrieved
.
This is my model:
$this->db->select('*',FALSE);
$this->db->from('t_penomoran tp');
$this->db->join('t_penomoran_detail t_pd', 'tp.nomor = t_pd.nomor');
$this->db->where('tp.nomor',$nomor);
$query = $this->db->get();
return $query->result_array();
note:
For some reason when I do alert(result.length)
with data that has no value, the result is 2
. But when I do alert(result)
with data that has no value the result is []