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

114
Visualizações
Autocomplete of input field with a lot of data

I am trying to create a search field, searching for cities in Denmark. I have an API with JSON to get all the cities, but there is a lot of data and therefore it takes time to load the page.

Is there any way, that I can load data from this API after the user has typed in the field?

Here is a snipped of the javascript/php I am using to get the data. Here you can see the link of all the cities too.

var cities = [];

            <?

                $citiesData = file_get_contents('https://api.dataforsyningen.dk/steder?hovedtype=Bebyggelse&undertype=by');
                $cityJson = json_decode($citiesData, true);

                for ($x = 0; $x <= count($cityJson) - 1; $x++) {
            ?>
                    cities.push("<? echo $cityJson[$x]["primærtnavn"]; ?>");

            <?
                }
            ?>

After this I am using the autocomplete javascript function from W3School, which can be found here: https://www.w3schools.com/howto/howto_js_autocomplete.asp

How can I make this so it does not take long for the page to load?

about 4 years ago · Juan Pablo Isaza
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