Porblems accesing array elements; possible scope issue.

Porblems accesing array elements; possible scope issue.

Hi I'm completely stumped, can someone help please?

The below code executes without errors in chrome and firefox but the alert returns 'undefined' even though images[] is populated correctly with string paths when I test from the browser consoles.
can anyone see the problem?
  1. <script type="text/javascript">
    var images = new Array();
    $(document).ready(function() {
      $.getJSON("images/research/getImgs.php", function(json){
        for(var i=0;i<json.length;i++) {
          images[i] = json[i];
        }
      });
      alert(images[1]);
      $('#slideshow').attr("src", images[1]);
    });

    </script>












many thanks
Tim