title: How to get a variable returned across multiple functions - Javascript/jQuery
body: <p>This question in summary is to figure out how to pass variables between javascript functions without: returning variables, passing parameters between primary functions, using global variables, and forcing function 1 to wait for function 2 to finish.  I figured out a jQuery solution and posted in below (in the answers section).</p>
  
  <hr>
  
  <p>Old Post: I initialize a set of four functions, each calling on each other in a different way.  At the end of it, I need the final modified product (an array) returned to the initializing function.  </p>
  
  <p>Global variables don't force the initial function to wait.  And returning it backwards four times doesn't work either.  How do you pass a modified variable back to its initializing function, if you can't return it?  Or why isn't it returning?</p>
  
  <p>(the maze starts at <code>initFunctionA</code>, ends at <code>functionD</code>)</p>
  
  <pre><code>classOne = {
    initFunctionA : function() {
      classTwo.functionB(functionD, array);
      // I NEED ACCESS TO ARRAY2 HERE
    },
    functionD : function(data, array) {
      var array2 = // modifications to array
    }
  }
  
  {...}
  
  classTwo = {
    functionB : function(callback, array) {
      $.ajax({
        success: function(ret){
          classTwo.functionC(ret, callback, array)
        }
      });
    },
    functionC : function(ret, callback, array) {
       callback(ret.data.x, array);
    }
  }
  </code></pre>