title: Select2 v4 how to paginate results using AJAX
body: <p>I'm trying to paginate results (every 25 rows) using Select2 4.0, but I don't know how to achieve it. Does somebody know how to do it? </p>
  
  <p>If the user reach the end of the 25 rows and if there is more rows I would like to load it and show it.</p>
  
  <p>Here is my HTML template</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      {!! Form::select('breed_id', $breeds, null, ['class' =&gt; 'form-control', 'id' =&gt;'breed_id'] ) !!}
  &lt;/div&gt;
  </code></pre>
  
  <p>And here is the JavaScript for Select2.</p>
  
  <pre><code>$("#breed_id").select2({
      placeholder: 'Breed...',
      width: '350px',
      allowClear: true,
      ajax: {
          url: '',
          dataType: 'json',
          data: function(params) {
              return {
                  term: params.term
              }
          },
          processResults: function (data, page) {
              return {
                  results: data
              };
          },
          cache: true
      }
  });
  </code></pre>
  
  <p>And this is the code I have for my controller</p>
  
  <pre><code>if ($request-&gt;ajax())
  {
      $breeds = Breed::where('name', 'LIKE',  '%' . Input::get("term"). '%')-&gt;orderBy('name')-&gt;take(25)-&gt;get(['id',DB::raw('name as text')]);
  
      return response()-&gt;json($breeds);
  }
  </code></pre>
  
  <p>Also when I tried to put <code>params.page</code> it says "undefined".</p>