Here's my code:
$(document).ready(function() {
    var myArray = [];
    $.getJSON("some url",function(data){
        $.each(data, function(){
            myArray.push("a string" + this);
        });
        alert(myArray);
    });
    //alert(myArray);
});
The code as shown is working just fine and it displays the array and its contents.
However, when I try to display the array by having the command line right after the $.each code block (commented out in the sample code), the array and its contents are not displayed. An empty/ blank message is returned instead. 
Why is this happening and how can I fix it? I'd like to have the command "alert(myArray);" right after the $.each block.
Thank you in advance!
 
     
    