Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
Select2: Searching not working with external json file

0.13) to load a json with country names. I can show and select the data correctly, but the searching is not working.

Everytime I type something it always returns all the values and not the ones I'm searching for.

This is my code:

$("#reg_afi_nac").select2({
       width: '100%',
       placeholder: 'Ingrese la nacionalidad',
       language: 'es',
       ajax: {
           url: "<?php echo base_url('assets/json/nacionalidades.json') ?>",
           dataType: "json",
           type: "POST",
           data: function(params) {
               return {
                   q: params.term, // search term
               };
           },
           processResults: function(data) {
               return {
                   results: $.map(data, function(item) {
                       return {
                           text: item.text,
                           id: item.text
                       }
                   })
               };
           },

           cache: true,
       },

   });
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda