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

116
Views
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 answers
Answer question

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 Report

0

You can use an input with datalist.

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

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