title: Can't access JSON length property via Jquery
body: <p>I'm trying to fill divs with different PDF's embedded on iframe tags, the src of the pdfs are taken from this json file:</p>
  
  <pre><code>{  
  
  
  "0" : {
        "ID": "Doc1", 
        "URL":"http://192.168.13.158/31818_E-(1).PDF"
     },
  
     "1" : {
        "ID": "Doc1", 
        "URL":"http://192.168.13.158/31818_P-(1).pdf"
     },
  
     "2" : {
        "ID": "Doc1", 
        "URL":"http://192.168.13.158/31818_P-(2)%20(1).pdf"
     },
  
     "3" : {
        "ID": "Doc1", 
        "URL":"http://192.168.13.158/31818_T-(1).pdf"
     },
  </code></pre>
  
  <p>This is the whole jquery code:</p>
  
  <pre><code>    &lt;script&gt;
    $( document ).ready(function() {
      var json = (function() {
        json = null;
        $.ajax({
          'async': false,
          'global': false,
          'url': "planos.json",
          'dataType': "json",
          'success': function (data) {
            json = data;
          }
        });
        return json;
      })();
      /*Add Read Document Marker + PDF Reader*/
        $(".panel-title .document-link").click(function(e) { 
          for (var i = 0; i &lt; Object.keys(json).length; i++){
            var dataOrderSelected=$(this).attr('data-order');
            if ( (dataOrderSelected == i) &amp;&amp; ($("iframe[data-order='"+dataOrderSelected+"']").attr("src",""))) 
            {
              $("iframe[data-order='"+dataOrderSelected+"']").attr('src', json[i].URL);
            } 
          };  
        });
      /*Add Read Document Marker + PDF Reader*/  
    });      
  &lt;/script&gt;   
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <pre><code>*Uncaught TypeError: Cannot convert undefined or null to object
  at Function.keys (&lt;anonymous&gt;)
  at HTMLAnchorElement.&lt;anonymous&gt; (audits-paso-2-tabs.html:423)
  at HTMLAnchorElement.dispatch (jquery.min.js:5)
  at HTMLAnchorElement.v.handle (jquery.min.js:5)*
  </code></pre>
  
  <p>So what i'm guessing is that that part of my jquery can't access the json variable (Object.keys(<strong>json</strong>).length). Any help would be really appreciate, im a newbie regarding how to deal with json files on this context. Many Thanks in advance. </p>