title: Select2: Uncaught TypeError: options.results is not a function
body: <p>I am attempting to do an AJAX call with the Select2 jquery plugin. The query seems to be working, but the issue occurs when <code>.results()</code> is called on the <code>options</code> object:</p>
  
  <p><code>Uncaught TypeError: options.results is not a function</code></p>
  
  <p>Here is my HTML:</p>
  
  <pre><code>&lt;input class="form-control" type="number" value="2125" name="topic_relation[source_topic_id]" id="topic_relation_source_topic_id" /&gt;
  </code></pre>
  
  <p>Here is my JS:</p>
  
  <pre><code>$(document).ready(function() {
    $('#topic_relation_source_topic_id').select2({
      minimumInputLength: 3,
      ajax: {
        url: "&lt;%= grab_topics_path %&gt;",
        dataType: 'json',
        delay: 250,
        data: function (term, page) {
          return {
            q: term, //search term
            page_limit: 30, // page size
            page: page, // page number
          };
        },
        processResults: function (data, page) {
          var more = (page * 30) &lt; data.total;
          return {results: data.topics, more: more};
        }
      },
      formatResult: topicFormatResult,
      formatSelection: formatRepoSelection,
      escapeMarkup: function (m) { return m; }
    });
    function topicFormatResult(topic) {
      return topic.name
    }
    function formatRepoSelection(topic) {
      return '&lt;option value="'+ topic.id +'"&gt;' + topic.name + '&lt;/option&gt;'
    }
  });
  </code></pre>
  
  <p>Here is the returned JSON:</p>
  
  <pre><code>{"total":2, "topics":[{"id":305,"name":"Educational Assessment, Testing, And Measurement"},{"id":3080,"name":"Inspectors, Testers, Sorters, Samplers, And Weighers"}]}
  </code></pre>
  
  <p>Here is the code which is failing:</p>
  
  <pre><code>function ajax(options) {
      var timeout, // current scheduled but not yet executed request
          handler = null,
          quietMillis = options.quietMillis || 100,
          ajaxUrl = options.url,
          self = this;
  
      return function (query) {
          window.clearTimeout(timeout);
          timeout = window.setTimeout(function () {
              var data = options.data, // ajax data function
                  url = ajaxUrl, // ajax url string or function
                  transport = options.transport || $.fn.select2.ajaxDefaults.transport,
                  // deprecated - to be removed in 4.0  - use params instead
                  deprecated = {
                      type: options.type || 'GET', // set type of request (GET or POST)
                      cache: options.cache || false,
                      jsonpCallback: options.jsonpCallback||undefined,
                      dataType: options.dataType||"json"
                  },
                  params = $.extend({}, $.fn.select2.ajaxDefaults.params, deprecated);
  
              data = data ? data.call(self, query.term, query.page, query.context) : null;
              url = (typeof url === 'function') ? url.call(self, query.term, query.page, query.context) : url;
  
              if (handler &amp;&amp; typeof handler.abort === "function") { handler.abort(); }
  
              if (options.params) {
                  if ($.isFunction(options.params)) {
                      $.extend(params, options.params.call(self));
                  } else {
                      $.extend(params, options.params);
                  }
              }
  
              $.extend(params, {
                  url: url,
                  dataType: options.dataType,
                  data: data,
                  success: function (data) {
                      ========&gt; var results = options.results(data, query.page, query); &lt;==========
                      query.callback(results);
                  },
                  error: function(jqXHR, textStatus, errorThrown){
                      var results = {
                          hasError: true,
                          jqXHR: jqXHR,
                          textStatus: textStatus,
                          errorThrown: errorThrown
                      };
  
                      query.callback(results);
                  }
              });
              handler = transport.call(self, params);
          }, quietMillis);
      };
  }
  </code></pre>