title: Combine 2 ajax calls into 1 callback
body: <p>I'm building a Chrome extension and I need to combine 2 separate AJAX calls so that I have 1 callback on success. What is the best way to do that?</p>
  
  <pre><code>Auth.prototype.updateContact = function(id, contact_obj) {
    var self = this,
        contact_str = JSON.stringify(contact_obj);
  
    return new RSVP.Promise(function(resolve, reject) {
      self.authorize()
        .then(function() {
          $.ajax({
            type: "PUT",
            url: self.url + "contacts/" + id,
            contentType: "application/json; charset=utf-8",
            data: contact_str,
            dataType: "json",
            success: function(data) {
              resolve(data);
            },
            error: function(jqXHR, textStatus, errorThrown) {
              var msg = "updateContact error: request: " + id + " " +
                    contact_str + " response: " + jqXHR.responseText +
                    " e=" + JSON.stringify(errorThrown);
              sendErrorBackground(msg);
              reject(jqXHR);
            }
          });
        });
    });
  };
  
  Auth.prototype.updateContactList = function(id, list_obj) {
    var self = this,
        list_str = JSON.stringify(list_obj);
  
    return new RSVP.Promise(function(resolve, reject) {
      self.authorize()
        .then(function() {
          $.ajax({
            type: "POST",
            url: self.url + "add_lists",
            contentType: "application/json; charset=utf-8",
            data: list_str,
            dataType: "json",
            success: function(data) {
              resolve(data);
            },
            error: function(jqXHR, textStatus, errorThrown) {
              var msg = "updateContactList error: request: " + id + " " +
                    list_str + " response: " + jqXHR.responseText +
                    " e=" + JSON.stringify(errorThrown);
              sendErrorBackground(msg);
              reject(jqXHR);
            }
          });
        });
    });
  };
  </code></pre>
  
  <p>Attempt at using @Saar's suggestion</p>
  
  <pre><code>Auth.prototype.updateContact = function(id, contact_obj, list_obj) {
    var self = this,
        contact_str = JSON.stringify(contact_obj),
        list_str = JSON.stringify(list_obj);
  
  
    var promiseA = new RSVP.Promise(function(resolve, reject) {
          self.authorize().then(function() {
            $.ajax({
              type: "PUT",
              url: self.url + "contacts/" + id,
              contentType: "application/json; charset=utf-8",
              data: contact_str,
              dataType: "json",
              success: function(data) {
                return data
              }
            });
          });
        });
  
    var promiseB = new RSVP.Promise(function(resolve, reject) {
      self.authorize().then(function() {
          $.ajax({
            type: "POST",
            url: self.url + "add_lists",
            contentType: "application/json; charset=utf-8",
            data: list_str,
            dataType: "json",
            success: function(data) {
              return data
            }
          });
        });
      });
  
    $.when(promiseA, promiseB).then(function(resultA, resultB) {
      console.log(resultB);
    });
  };
  </code></pre>