title: Passing object to Callback in Javascript
body: <p>I'm trying to write a function with a callback -- I want to create an object, and then access that data in the callback.</p>
  
  <p>Here is my function so far:</p>
  
  <pre><code>var getModelInfo = function(model, callback) {
        alert('called!')
  
        //This logs the correct model
        console.log(model);
  
        //The object I want to return
        return {
          "field1" : model.get("1"),
          "field2" : model.get("2"),
          "field3" : model.get("3"),
          "field4" : model.get("4")
  
        };
  
      }
  
      //Declared outside because I want to avoid 'this' issues
      var model_send = this.model;
  
      $(function() {
        alert('callback to be called')
        getModelInfo(model_send, function(data) {
          alert('call back called');
  
          // I want this to be the returned object
          console.log(data)
  
        });
  
      });
  </code></pre>
  
  <p>As of right now, 'callback to be called' alerts before 'called', but 'call back called' never alerts. How can I access that returned data in the callback?</p>
  
  <p>Please feel free to let me know if I'm doing anything else wrong too! </p>