Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

233
Vistas
how to custom output select2 ajax remote data

I want to create select2 with content flag, name country, and calling Codes. I have some problems with my code because I can't show the output what I want.

var countriesList = "https://restcountries.com/v2/all";




$.ajax({
  type: "GET",
  url: countriesList,
  dataType: "json",
  success: function (response) {
    $(".js-data-example-ajax").select2({
      data: response.map((e) => ({
        id: e.alpha2Code,
        text: e.name,
      })),
      width: 300,
      dropdownAutoWidth: true,
    });
  },
  error: function () {},
  complete: function () {},
});

from this enter image description here

to this enter image description here

7 months 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 empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.