title: Variable scope question in my jQuery
body: <p>I am having a problem with the scope of my variables after having retrieved them from a back-end PHP script as a 2-dimensional JSON array. Here is my code:</p>
  
  <pre><code>var qns, qis, ncs, nzs, tps;
  
  function get_questions() {
      var url = "php/pytania.php";
      $.ajax({
          cache: false,
          type: "GET",
          dataType: "text",
          url: url,
          success: function(response) {
              data = jQuery.parseJSON(response);
              qns = data.qns;
              qis = data.qis;
              ncs = data.ncs;
              nzs = data.nzs;
              tps = data.tps;
          }
      });
  }
  
  $(document).ready(function() {
      var index = 0;
      get_questions();
      $("#question_no").text(qns[index]);
  });
  </code></pre>
  
  <p>When I try to reference my qns array in the end, it displays a variable undefined error. It works however within the ajax statement - no problems there...</p>
  
  <p>Thanks and take care! :)</p>
  
  <p>Piotr.</p>