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

153
Views
La búsqueda Select2 no devolverá el resultado

Tengo un problema con la búsqueda cuando se carga Ajax desde json. Digamos que busco Yemen, el registro de Yemen no se seleccionará ni resaltará.

Aquí está la fuente completa, ¿alguna configuración no se realizó correctamente?

 <html> <head> <script src="https://code.jquery.com/jquery-3.6.0.min.js" ></script> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script> <script> jQuery(document).ready(function() { $('#allowedCountries').select2({ placeholder: 'Select allowed countries', allowClear:true, tokenSeparators: [',', ' '], ajax: { dataType : "json", url : "countries2.json", }, }); }); </script> </head> <body> for select2<Br> <div style="width:100%"> <select name="allowedCountries" class="js-states form-control" id="allowedCountries"><option></option></select> </div> </body> </html>

Luego, para el archivo json, datos de muestra

 { "results": [ { "id": 1, "text": "Afghanistan" }, { "id": 2, "text": "Aland Islands" }, { "id": 3, "text": "Albania" }, { "id": 245, "text": "Yemen" }, { "id": 246, "text": "Zambia" }, { "id": 247, "text": "Zimbabwe" } ] }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Desplazarse rápidamente por la documentación oficial, ¿podría ser esto un problema?

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza Report
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!