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

121
Vistas
how to add search in select option when data fetching from ajax call

enter image description here

enter image description here

enter image description here

enter image description here

search bar is added but data not fetching in selectize jquery and at the normal side are working fetch data option tag but after adding search bar in drop down it can not working so please help

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

This is the simple version of your task. So may be it will helpful for you:

let url = 'https://rickandmortyapi.com/api/character/?page=1';
let isOpen = false;
const select = document.querySelector('#characters');

const getCharacters = (isFirstRun) => {
  if (!isFirstRun) {
    isOpen = !isOpen;

    if (isOpen) return;
  }


  fetch(url)
    .then(response => response.json())
    .then(charactersData => {
      url = charactersData.info.next;
      select.innerHTML = '';
      return charactersData.results.map(charactersData => charactersData.name);
    })
    .then(charactersNames => charactersNames.forEach(characterName => {
      const option = document.createElement('option');
      option.innerText = characterName;
      select.appendChild(option);
    }))
    .catch(e => console.log(e.message));
}

getCharacters(true);
<select id="characters" onclick='getCharacters()'></select>

about 4 years ago · Santiago Trujillo Denunciar

0

You can use an input with datalist.

https://developer.mozilla.org/de/docs/Web/HTML/Element/datalist

about 4 years ago · Santiago Trujillo Denunciar
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