title: JavaScript accessing vriable
body: <p>i have this javascript code for accessing a JSON. There is a variable v1 that i declared global, but i can't access it outside this function.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    $.ajax({
              type: 'GET',
              url: url,
              async: true,
              jsonpCallback: 'jsonCallback',
              contentType: "application/json",
              dataType: 'jsonp',
              success: function(json) {
                  //console.log("good");
                  v1 = [];
                  $.each(json, function(key, val) {
                     // $('ul').append('&lt;li id="' + key + '"&gt;' + val.dir + ' ' + val.nr  + '&lt;/li&gt;');
                     if(val.dir === "IESIRE"){
                        // console.log(val.data);
                         v1.push(val.data);
                     }
                  });
              },
              error: function(e) {
                  console.log(e.message);
              }
          });
  
      console.log(v1);</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please help to understand this.</p>