I have been working on this little app which sends an AJAX GET request to an URL which gives a JSON reply with PHP json_encode()
function and when I try to access any individual response JSON value, it says undefined but the console.log()
of the whole response gives me VALID JSON!
What am I doing wrong here please?
UPDATE with code: The code is written using Codeigniter. Here is the server side code.
public function getByIdModel($id){
$sql = "SELECT * FROM `pop_proj` WHERE `id`= $id";
$query = $this->db->query($sql);
$result = $query->result();
return json_encode($result );
}
public function getByIdController() {
$this->load->model('Crud_model');
$query = $this->Crud_model->getById('394857');
echo json_encode($query);
}