title: javascript variable is undefined
body: <p>I'm writing a small Flickr image grabber app, and we have a JSON proxy on our own servers. The function below grabs the images from a photoset given the <code>id</code>.</p>
  
  <pre><code>function getPhotosFromPhotoset(p_id) {
      var data;
      $.getJSON('/flickr_get_photos', {
          photoset_id: p_id
      }, function(res) {
          data = res;
          console.log("res: " + JSON.stringify(data));
          if (res.status == 'ok') {
              if (res.data.length &gt; 0) {
                  //nada                                                                                                                            
              } else {
                  data.status = "error: Photoset has no photos.";
              }
          } else {
              data.status = "An unknown error occurred; please try again.";
          }
      });
      return data; //undefined?!
  }
  </code></pre>
  
  <p>Why is does <code>data</code> suddenly become undefined? When I <code>console.log</code> it inside of the <code>getJSON</code>, it's perfectly valid.</p>