title: not receiving JSON from php with getJSON
body: <p>I am trying to pass an array to the browser using php and jquery but I the when I try to use the 'data' returned from php's encode_json, it comes up undefined.  I'm just learning php, jquery, and json and so far haven't found very good documentation on alot of this stuff, especially json, even in the books I have.  Thanks in advance!</p>
  
  <p>Here is a stripped down version of the jquery I have</p>
  
  <pre><code>$(document).ready(function(){
      var jsonResult;//I will want to be able to use the data in other functions
  
      $.getJSON("json.php", function(data){  
          jsonResult = data;
          var str;
          var nuts = [203,204,205,207];
  
          str = '&lt;p&gt;' + data[nuts[0]].NutraDesc + '&lt;/p&gt;';
          $('#stuff').html(str);
          }
      );
  });
  </code></pre>
  
  <p>This is the php:
      
  
  <pre><code>    include_once 'databasePHP.php';
          $json_tst = $db-&gt;query( "SELECT  def.Nutr_No, NutrDesc, Nutr_Val, Units 
                  FROM nutr_def as def  JOIN nut_data as data  ON def.Nutr_No = data.Nutr_No 
                  WHERE data.NDB_No = 1001 LIMIT 0, 2");
  
          $food = array();
  
          while($row = $json_tst-&gt;fetch(PDO::FETCH_ASSOC))
          {
             $Nutr_No = $row['Nutr_No'];
             $food[$Nutr_No][] = array(
                 'NutrDesc' =&gt; $row['NutrDesc'],
                 'Nutr_Val' =&gt; $row['Nutr_Val'],
                 'Units' =&gt; $row['Units']
             );
          };
  
          echo  json_encode($food);
  ?&gt;
  </code></pre>
  
  <p>which returns this json which I checked on jsonlint.com and it said it was valid:</p>
  
  <pre><code> {"203":[{"NutrDesc":"Protein","Nutr_Val":"0.85","Units":"g"}],"204":[{"NutrDesc":"Total lipid (fat)","Nutr_Val":"81.11","Units":"g"}]}
  </code></pre>