Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!