title: JSON.parse is an “undefined” object
body: <p>I created json with php. Data coming with ajax. But JSON.parse is  giving an “undefined” object. Why ?</p>
  
  <p>Php CODE</p>
  
  <pre><code> $emparray = array();
   while($row =mysqli_fetch_assoc($result))
   {
       $emparray[] = $row;
   }
  
   echo json_encode($emparray);
  </code></pre>
  
  <p>Ajax CODE</p>
  
  <pre><code>   $.ajax({
          type: "GET",
          url: "http://localhost:8080/xxx.php/",
          success: function (msg, result, status, xhr) {
              var obj= JSON.parse(msg);
              alert(obj.name);// giving undefined
          },
          error: function (error) {
          }
      });
  </code></pre>
  
  <p>json</p>
  
  <pre><code>[{"name":"eng","a":"sdf"}]
  </code></pre>