My current <body>...<script>....</script></body> tab has this flow:
<script>
$(document).ready(function(){
    function main(){
        var urlOne = 'https:....';
        var summaryTable = {};
        var distinctKeys = [];
        $.getJSON(urlOne, function(jsonOne) {
            // write code to collect data from urlOne and put it in 'summaryTable' AND 'distinctKeys'
            distinctKeys.append(jsonOne['something']);
        }); // end of first getJSON
        /* ****** the javascript would NOT execute anything below this **** */
        var foo = distinctKeys.length;
        for (var i = 0; i < foo; i++) {
            var curUrl = urlConstant + distinctKeys[i];
            $.getJSON(curUrl, function(jsonTwo) {
                // do stuff to add more info into 'summaryTable'
            }); // end of second getJSON
        }; // end of for loop
    }; // end of main()
    main();
}); // end of all javascript code    
</script>
As I mentioned above, the code wouldn't proceed to execute anything below the /* ****** the javascript would NOT execute anything below this **** */ line. I notice that the distinctKeys and summaryTable are still empty once the first $.getJSON call is executed. I'd like to call getJSON two times in that particular order--the second time is based on the information obtained/collected from the first call. Could anyone explain how I could accomplish that?
Thank you in advanced for your answers!
 
    