title: jquery Select2 Ajax - How set value (initSelection)
body: <p>How set in the drop-down list item selected by the user?</p>
  
  <p>Scenario:<br />
  1. User not enter all required values in form<br />
  2. Click sent. <br />
  3. Page is refresh and value in dropdown list is not selected. <strong>How select the value?</strong></p>
  
  <p>I have working script which retrieve data for the list.</p>
  
  <pre><code>$('#userid').select2({
  placeholder : " --- select ---",
  minimumInputLength: 2,
  ajax: {
      url: "index.php?modul=getusers",
      contentType: 'application/json; charset=utf-8',
      dataType: 'json',
      data: function (term, page) {
          return {
              q: term,
              page_limit: 10
          };
      },
      results: function (data, page) {
          return { results: data };
      }
  },
  allowClear: true,
  formatSelection: function(data) { 
     return data.text; 
  }   
  });
  </code></pre>
  
  <p>Standard data in ajax call:
  {"text":"sample text", "id":"1"}</p>
  
  <p>Input:
      <pre>  &lt;input type="text" value="&lt;? echo $_POST['userid']; ?&gt;" class="input" id="userid" name="userid"&gt; </pre></p>
  
  <p>I tried to add the following code, but it doesn't work</p>
  
  <pre><code>initSelection: function(element, callback) {
      var id=$(element).val();
      if (id!=="") {
         $.ajax("index.php?modul=getusersfriend&amp;q="+id, {
         dataType: "json"
         }).done(function(data) { callback(data); });
      }
  },
  </code></pre>