title: Need 2 functions to run onLoad with Ajax - only 1 working
body: <p>Starts with shuffle functions (just shuffles arrays). It works.
  Then I define 2 global variables that will determine the random order for images to be displayed on the page.
  picOrder will be a simple array from 0 to picCount, with picCount determined by Ajax onload. The picCount is being retrieved, but the the picOrder array is not being set! If I manually run "arrangePics();" in the console it works. It fills the array picOrder and then shuffles it. But it does not work by placing the calls to both functions inside "" or by putting the "doStuff()" function in there.</p>
  
  <pre><code>Array.prototype.shuffle = function() {
  var s = [];
  while (this.length) s.push(this.splice(Math.random() * this.length, 1)[0]);
  while (s.length) this.push(s.pop());
  return this;
  }
  
  var picOrder = new Array();
  var picCount;
  
  function getPicCount() {
  //  picCount = array(10);
      if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
        } else {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
              picCount = xmlhttp.responseText;
          }
        }
      xmlhttp.open("GET","/example.com/images.php?count=hello",true);
      xmlhttp.send();
      //picCount.shuffle;
  
  }
  
  function arrangePics() {
      for(var i = 0;i&lt;picCount;i++) {
      picOrder[i] = i;
      }
      picOrder.shuffle();
      //alert(picOrder);
  }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;body onLoad="getPicCount();arrangePics();"&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;body onLoad="doStuff();"&gt;
  </code></pre>