Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

You can use an input with datalist.

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

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda