title: jQuery $.ajax(), pass success data into separate function
body: <p>I am using the jQuery $.ajax() function.  I have put this into a parent function, which passes some values into the ajax function.  What I would like to do, is have a user defined callback function, which gets the data param passed in from the ajax success function.</p>
  
  <p>Here is what I was thinking would work, but it is not:</p>
  
  <pre><code>testFunc = function(str, callback) {
      // Send our params
      var data = 'some data to send';
      $.ajax({
          type: 'POST',
          url: 'http://www.myurl.com',
          data: data,
          success: callback
      });
  }
  </code></pre>
  
  <p>Then I want to be able to call that function, and pass in my custom function so that I can use the success functions data from inside that function:</p>
  
  <pre><code>testFunc('my string data', function(data){
      alert(data);
  });
  </code></pre>
  
  <p>I am wanting this to be the same as:</p>
  
  <pre><code>testFunc = function(str, callback) {
      // Send our params
      var data = 'some data to send';
      $.ajax({
          type: 'POST',
          url: 'http://www.myurl.com',
          data: data,
          success: function(data) {
              alert(data);
          }
      });
  }
  </code></pre>