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

280
Visualizações
Providing different content out of a .json-file of a "Travel-Website" when clicking the links of the different countries

First of all, I would like to apologize for the complicated style of my question. I am developing a website for a friend who runs a local bus company.

Several trips (4-5 pieces) are made a year to different destinations. These change every year. I have a .JSON file in which I store the different destinations as objects in an array, making it easy to adjust yearly.

On the start page "cards" are displayed which generate the content and themselves via xhttp request (javascript). Now I want to create another .html page, which after clicking a map (e.g. Munich) pulls the .JSON data and feeds the overview page with it.

I have both the cards and the overview page. However, after hours of thinking and trying, I don't see a way to adapt the link so that it displays the data of the corresponding destination on the overview page. I can only adjust this if I manually enter e.g. ${data[2].heading}.

Example code for the cards:

//XML-Request
const mainContainer = document.querySelector(".main_container");
var xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function(){
    if(this.readyState == 4 && this.status == 200){
        var response = JSON.parse(xhttp.responseText);
        var data = response.cities;

        for(i=0; i<data.length;i++){

            var card = document.createElement("div");
            card.className = `karte`;

            let cardContent = `<h1>Urlaub in ${data[i].name} </h1>
            <button class="btn ${data[i].id}" onclick="openWindow()">Ab nach ${data[i].name}</h1>`

            card.innerHTML = cardContent;
            mainContainer.appendChild(card);
        }

    }
}

xhttp.open("GET", "data.json", true);
xhttp.send();strong text

Is there any way to customize the links accordingly? Happy to learn PHP or similar if it solves my problem... just need some food for thought on how to approach it for now.

Thank you in advance.

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