title: Define a callback for a function that utlizies DATA parameter from AJAX call
body: <p>I am trying to save the HTML from a <code>&lt;textarea&gt;</code> as an email template.  This can be done in multiple places so I want to create a <code>save_email_template()</code> function that can receive parameters and save as needed (which I've sucessfulyl done). </p>
  
  <p>I also want to specifiy a callback each time the  <code>save_email_template()</code> function is called. The catch is inside the callback I want to handle the <code>data</code> returned from an ajax call inside the <code>save_email_template()</code> function in a variety of ways. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>function save_email_template(options,callback){
  
     $.ajax({
        type: "POST",
        url: '/save_email_template.php',
        data: options.params,
        success:function(data) {
  
          if (typeof callback === 'function') {
              callback(data);
          }
        }
     });
   }
  
  
     save_email_template({
        params: {
          'action':'add',
          'eid':$('input#id').val(),
          'title':$('input#name').val(),
          'html':$('textarea#html').val()
        }
      }, function(data){ // &lt;----  "Data" Not Defined 
  
          if (typeof data.html_issues !== 'undefined') {
              console.log('HTML Issues:\n------------------');
              console.error(data.html_issues);
          }
  
          if (typeof data.css_issues !== 'undefined') {
              console.log('CSS Issues:\n------------------');
              console.error(data.css_issues);
          }
  
          if (data.status == "OK") {
               $('body').append(data.html);
          } else {
              if (typeof data.error_msg !== 'undefined')
                alert(data.error_msg);
  
              if (data.status == "ERROR")
                console.error(data);
          }
      });
  </code></pre>
  
  <p><strong>THE ISSUE:</strong> </p>
  
  <p>I keep getting the JS error '"data" not defined'  and its referencing my callback... this code <code>function(data){...}</code>. Obviosly <code>data</code> is not yet defined, but how to I reference the <code>data</code> returned in the AJAX call? </p>