title: The results could not be loaded when searching for users
body: <p>I need to implement select2 with ajax, and I'm using <a href="https://github.com/NeilMeredith/Select2Demo/blob/master/Select2Demo/Views/Home/Index.cshtml" rel="nofollow noreferrer">this</a> as an example project to work from.</p>
  
  <p>This is what I have so far</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;div class="col-md-10"&gt;
          &lt;select class="js-data-example-ajax form-control"&gt;&lt;/select&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  $(document).ready(function () {
  
      $('.js-data-example-ajax').select2({
          placeholder: 'Enter name',
          //Does the user have to enter any data before sending the ajax request
          minimumInputLength: 3,
          allowClear: true,
          ajax: {
              quietMillis: 150,
              // url: '@Url.Action("GetUsers", "CRMTItems")',
              url: '/CRMTItems/GetUsers/' + $('.js-data-example-ajax').text(),
              dataType: 'jsonp',
              results: function (data) {
                  console.log('results');
                  return { results: data.results }
              }
              // Additional AJAX parameters go here; see the end of this chapter for the full code of this example
          }
      });
  )};
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public JsonResult GetUsers(string term)
  {
      var users = CRMTItemViewModel.AllUsers.Where(u =&gt; u.DisplayName.Contains(term));
      var userList = AttendeesToSelect2Format(users, 10);
      return Json(userList, JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>I can see that the search term is passed in and the data is filtered, but when it gets sent back to the view I just see</p>
  
  <p><a href="https://i.stack.imgur.com/TfknM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TfknM.png" alt="enter image description here"></a></p>
  
  <p>I tried copying the sample project exactly, but then I ran into further issues:</p>
  
  <ol>
  <li><p>When using <code>@Html.TextBoxFor</code> instead of <code>&lt;select&gt;</code> I just see</p>
  
  <blockquote>
    <p>No select2/compat/inputData</p>
  </blockquote>
  
  <p>in the js console</p></li>
  <li><p>When copying the js exactly (with the <code>data</code> and <code>results</code> function), my search term never makes it to the controller, and <code>null</code> is passed in every time..</p></li>
  </ol>
  
  <p>Please can someone help with this I don't get it</p>