title: How can I pass a callback function into an $.ajax.done callback?
body: <p>I'm calling a function, which makes an <code>ajax GET</code> to a url, like this:</p>
  
  <pre><code>// parameters = url, callback, boolean
  that.mapUrl( window.location.search, function(spec) {
      console.log("initial mapping done");
      console.log(spec);
      // do stuff
    }, true);
  </code></pre>
  
  <p><code>mapUrl</code> will trigger an Ajax request. Inside the Ajax <code>done</code> or <code>success</code> handler, I want to trigger my callback function, but doing it like this:</p>
  
  <pre><code>$.ajax({
    method: 'GET',
    url: obj[1],
      context: $('body')
    }).fail(function (jqXHR, textStatus, errorThrown) {
      console.log("FAILED");
      configuration = {
        "errorThrown":errorThrown,
        "textStatus": textStatus,
        "jqXHR": jqXHR
      }    
    }).done(function(value, textStatus, jqXHR) {
      console.log("OK");
      console.log(callback) // undefined!
      configuration = {
        "value":value,
        "textStatus": textStatus,
        "jqXHR": jqXHR
      }
    });
  </code></pre>
  
  <p><strong>Question</strong>:<br>
  So I'm wondering how to pass my callback function into the <code>ajax</code> <code>done-callback</code>. Any idea how to do this?</p>
  
  <p>Thanks! </p>
  
  <p><strong>EDIT</strong><br>
  Here is the full <code>mapURL</code> function</p>
  
  <pre><code>that.mapUrl = function (spec, callback, internal) {
    var key,
      obj,
      parsedJSON,
      configuration = {"root" : window.location.href};
  
    if (spec !== undefined &amp;&amp; spec !== "") {
      obj = spec.slice(1).split("=");
      key = obj[0];
      console.log(key);
      switch (key) {
      case "file":
        $.ajax({
          method: 'GET',
          url: obj[1],
          context: $('body')
        }).fail(function (jqXHR, textStatus, errorThrown) {
          console.log("FAILED");
          configuration = {
            "errorThrown":errorThrown,
            "textStatus": textStatus,
            "jqXHR": jqXHR
          }
        }).done(function(value, textStatus, jqXHR) {
          console.log("OK");
          configuration = {
            "value":value,
            "textStatus": textStatus,
            "jqXHR": jqXHR
          }
        });
        break;
      default:
        // type not allowed, ignore
        configuration.src = [];
        break;
      }
    }
    return configuration;
  };
  </code></pre>