title: How to access JSON object property from data returned by AJAX call?
body: <p>I'm making an AJAX call to this php file:</p>
  
  <pre><code>&lt;?php 
      $result = array('error' =&gt; "Please enter a valid name");
      echo  json_encode($result)
  ?&gt;
  </code></pre>
  
  <p>In my javascript file, I have:</p>
  
  <pre><code>$.ajax({
      type:"POST",
      url:"/controller/common/review_processing.php", 
      data:dataString, 
      success:function (data) {
          var returned_data = data;
          console.log(returned_data); &lt;---This outputs {"error":"Please enter a valid name"} 
          console.log(returned_data.error); &lt;---This outputs undefined
      }
  
  });
  </code></pre>
  
  <p>My data seems to be encoded as a JSON object correctly but when I try to access a specific property, I get an undefined result.</p>
  
  <p>What I want is for <code>console.log(returned_data.error)</code> to output:</p>
  
  <blockquote>
    <p>Please enter a valid name</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>