title: Cannot read property 'length' of undefined with $.getJSON
body: <pre><code>function loadCountries(clicked_cat){    
  
  $.getJSON('my.json', function(data) {
        var items = [];
        $.each(data.Category_1, function(key,val) {
          items.push('&lt;li id="' + key + '"&gt;' + val + '&lt;/li&gt;');
        });
  
        $('&lt;ul/&gt;', {
          'class': 'my-new-list',
          html: items.join('')
        }).appendTo('#myDiv');
      });
  }
  </code></pre>
  
  <h2>What this does:</h2>
  
  <p>It loads json file perfectly. I am using <code>data.Category_1</code> to access the JSON elements.</p>
  
  <h2>What I am not able to do:</h2>
  
  <p>I need to add a variable in place of <code>Category_1</code> in <code>data.Category_1</code>.
  It should be something like <code>data.clicked_cat</code> where <code>clicked_cat</code> gives me details like <code>Category_1</code> , <code>Category_2</code> etc.</p>