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

376
Views
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

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!