title: How to get JSON response into variable from a jquery script
body: <p>I am having trouble with my jQuery script below, this is a basic stripped down version and even it will not work,  I have the php file that the jQuery script makes a call to, I have it set to encode and show a JSON response</p>
  <p>Then in the jQuery script it should read the value and respond to it but It is not getting the response.</p>
  <p>Is <code>json.response</code> the wrong way to call a variable in the JSON string that is name response?</p>
  <pre><code>&lt;?php
  header('Cache-Control: no-cache, must-revalidate');
  header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  header('Content-type: application/json');
  
  // set to retunr response=error
  $arr = array ('resonse'=&gt;'error','comment'=&gt;'test comment here');
  echo json_encode($arr);
  ?&gt;
  
  //the script above returns this:
  {&quot;response&quot;:&quot;error&quot;,&quot;comment&quot;:&quot;test comment here&quot;}
  
  &lt;script type=&quot;text/javascript&quot;&gt;
  $.ajax({
      type: &quot;POST&quot;,
      url: &quot;process.php&quot;,
      data: dataString,
      dataType: &quot;json&quot;,
      success: function (data) {
          if (json.response == 'captcha') {
              alert('captcha');
          } else if (json.response == 'error') {
              alert('sorry there was an error');
          } else if (json.response == 'success') {
              alert('sucess');
  
          };
      }
  
  })
  &lt;/script&gt;
  </code></pre>
  <p>UPDATE:</p>
  <p>I have changed</p>
  <pre><code>json.response  
  </code></pre>
  <p>into</p>
  <pre><code>data.response  
  </code></pre>
  <p>But this did not make it ork either</p>