title: Have function return request data + a function to execute
body: <p>I have a function which gets a html file and displays it on the page but i want to tell it to also execute a function once the page has been dealt with. Except i don't know how to pass the data with it.</p>
  
  <p>This is what i currently have:</p>
  
  <pre><code>call_file('index.html', function(){ 
                          template_handler(
                              function(){ init_menu(); }
                          )}
      );
  }
  </code></pre>
  
  <p>This is handled like this:</p>
  
  <pre><code>function call_file(url,func){
      caller(url,function(){
          if ( xmlhttp.readyState== 4 &amp;&amp; xmlhttp.status== 200 ){
              call_back_fileLoad(xmlhttp.responseText,func);
          }
      });
  }
  function call_back_fileLoad(result,func){
  
          if(typeof(func) !== 'undefined'){       
              func(result);
          } else {
              return false;
          }
  }
  
  function caller(url,cfunc){
          if (window.XMLHttpRequest)
            {
              xmlhttp=new XMLHttpRequest();
            }
          else
            {
              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
              xmlhttp.onreadystatechange=cfunc;
              xmlhttp.open("GET",url,true);
              xmlhttp.send();
  }
  </code></pre>
  
  <p>The problem is i don't know how to receive the html &amp; the function i want to execute at the same time as it only returns one piece of data to the function.</p>
  
  <p>This is how i wish the final function to act:</p>
  
  <pre><code>function template_handler(data, func){
      var d = document.getElementById('content');
          d.innerHTML = '';
      var div = document.createElement(div);
          div.innerHTML = data;
  
      d.appendChild(div);
  
      func(); 
  }
  </code></pre>
  
  <p>Currently i don't know how to pass the data correctly for <code>call_file</code>, please help ^_^</p>