problem with image array

problem with image array

Hi, im stumped here:

This code executes without errors in chrome & FF but the alert returns 'undefined' even though if i open the javascript console and type 'images' the array of sting paths is returned fine.  Is this a scoping problem?

  1. 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]);
    });









many thanks,
Tim