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

274
Views
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
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!