code: function () {
              return function () {
                  return casper.wait(200)
                      .waitFor(function () {
                          var remainingAjaxRequests = this.evaluate(function () {
                              var amount = 0;
  
                              try {
                                  amount = CMS.$.active;
                              } catch (e) {}
  
                              return amount;
                          });
  
                          return remainingAjaxRequests === 0;
                      }).wait(200);
              };
          }
docs: Wait a bit and then wait until $.active will become 0.
  $.active is not documented, but it shows amount of ongoing
  jQuery requests.
  
  @function waitUntilAllAjaxCallsFinish
  @returns {Function}