0

I seen a website and I see JSON data that website and I'm to try do same like that everything working good but when I see his JSON in Chrome Developer Response his data coming in value is red but my data is coming in black please check image for more info.

This link of red json data that I see someone website:
this link of red json data that i see someone website

and this is my:
and this is my

This is my server side code

if($sql->num_rows > 0){
    while($row = $sql->fetch_assoc()){
        $nestedData["name"]             = $row["olduploadfilename"];
        $nestedData["size"]             = intval($row["uploadmissize"]);
        $data[] = $nestedData;
    }
    echo json_encode($data);
}
Nimantha
  • 6,405
  • 6
  • 28
  • 69

1 Answers1

0

The data in second image (your case) is not JSON type, it's plain text, so you should set the ContentType to application/json in your server.

Based on your code in your question you forgot following line:

header('Content-Type: application/json');

You can see more info right here: Returning JSON from a PHP Script

Mehdi Dehghani
  • 10,970
  • 6
  • 59
  • 64