title: Select2 "TypeError: a is undefined" error
body: <p>I've this code for create a <code>Select2</code> element from an input field:</p>
  
  <pre><code>var codigo_arancelario = $codigo_arancelario.val();
  
  $codigo_arancelario.select2({
      placeholder: "Seleccione un estado",
      ajax: {
          dataType: 'json',
          url: function () {
              return Routing.generate('obtenerCodigoArancelario');
          },
          data: function (codigo_arancelario) {
              return {
                  filtro: codigo_arancelario
              }
          },
          results: function (data) {
              var myResults = [];
              $.each(data.entities, function (index, item) {
                  myResults.push({
                      'id': item.id,
                      'nombre': item.nombre
                  });
              });
              return {
                  results: myResults
              };
          }
      },
      formatNoResults: function () {
          return "No se encontró el código";
      },
      formatAjaxError: function () {
          return "No hay conexión con el servidor";
      }
  });
  </code></pre>
  
  <p>But any time I try to use it I get this error on Firebug console:</p>
  
  <blockquote>
    <p>TypeError: a is undefined</p>
  </blockquote>
  
  <p>I checked the Response headers and I got a <code>Content-Type application/json</code> and also I check the Request headers since I'm using Symfony2 in the server side and it send the <code>X-Requested-With XMLHttpRequest</code>. The Symfony2 function return a JSON like this one:</p>
  
  <pre><code>{
     "valid":false,
     "entities":[
        {
           "id":101,
           "codigo":"4545",
           "descripcion":null
        },
        {
           "id":102,
           "codigo":"45455",
           "descripcion":"gfhgfhfghfgh"
        },
        {
           "id":103,
           "codigo":"45457",
           "descripcion":"etert"
        }
     ]
  }
  </code></pre>
  
  <p>Where is the error on my code?</p>