title: Jquery getJSON php array to javascript
body: <p>I am testing the getJSON with php array, but it is not working, can anyone check for me ? I feel the problem is from the php code because when i test the html code with getJSON url <a href="https://graph.facebook.com/zombies" rel="nofollow">https://graph.facebook.com/zombies</a>, it is working.  </p>
  
  <p>In my array.php</p>
  
  <pre><code>&lt;?php
  
   header("Content-type: text/javascript");
  
   $arr = array(
  
              "name" =&gt; "Tim",
              "age" =&gt; "28"     );
  
  echo json_encode($arr);
  
  ?&gt;
  </code></pre>
  
  <p>In my test.html :</p>
  
  <pre><code>  &lt;html&gt;
    &lt;head&gt;
      &lt;script type='text/javascript' src='jquery.js'&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
  
      &lt;script type='text/javascript'&gt;
  
      $(document).ready(function() {
           $.getJSON('array.php', function(data) {        
              if(data) {
              document.write(data.age);       
              }
              else {
              alert('error');
              }
          });
      }); 
      &lt;/script&gt;
  
     &lt;/body&gt;
     &lt;/html&gt;
  </code></pre>