Home JSON.parse() in AJAX response says undefined, why?
Reply: 0

JSON.parse() in AJAX response says undefined, why?

user969 Published in June 20, 2018, 1:30 am

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() {
    $query = $this->Crud_model->getById('394857');

    echo json_encode($query);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311179 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO