title: Passing a callback function to jQuery AJAX success function
body: <p>I'm trying to pass in a function to run when the AJAX call is successful, however it's not working as it say's that "callback is not a function".</p>
  
  <p>Example:</p>
  
  <p>Calling Code:</p>
  
  <pre><code>getGrades(var);    
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function getGrades(grading_company) {
  
      // Set file to get results from..
      var loadUrl = "ajax_files/get_grades.php";
  
      // Set data string
      var dataString = 'gc_id=' + grading_company;
  
      // Set the callback function to run on success
      var callback = 'showGradesBox';
  
      // Run the AJAX request
      runAjax(loadUrl, dataString, callback);
  
  }
  
  function showGradesBox(response) {
  
      // Code here...
  
  }
  
  function runAjax(loadUrl, dataString, callback) {
  
      jQuery.ajax({
          type: 'GET',
          url: loadUrl,
          data: dataString,
          dataType: 'html',
          error: ajaxError,
          success: function(response) {
              callback(response);
          }
      });    
  
  }
  </code></pre>
  
  <p>Now if I replace this line below with the function name itself it works:</p>
  
  <pre><code>callback(response);
  </code></pre>
  
  <p>But I can't get it to work like above where I get the function name from a passed in parameter.</p>