Untitled
plain_text
a month ago
1.8 kB
1
Indexable
Never
const aracButonlar = document.querySelectorAll('.arabaButon'); const popup = document.getElementById('popup'); const popupClose = document.getElementById('popup-close'); const popupId = document.getElementById('popup-id'); const popupMarka = document.getElementById('popup-marka'); const popupModel = document.getElementById('popup-model'); const popupYakit = document.getElementById('popup-yakit'); const popupBeygir = document.getElementById('popup-beygir'); const popupKoltuk = document.getElementById('popup-koltuk'); aracButonlar.forEach(button => { button.addEventListener('click', function() { const aracId = button.getAttribute('data-arac-id'); const apiUrl = `http://localhost:5116/Cars/${aracId}`; // API URL'sini düzgün bir şekilde güncelleyin fetch(apiUrl) .then(response => response.json()) .then(data => { // API'den gelen verileri pop-up penceresinde gösterme popupId.textContent = data.Id; popupMarka.textContent = data.Marka; popupModel.textContent = data.Model; popupYakit.textContent = data.Yakit; popupBeygir.textContent = data.Beygir; popupKoltuk.textContent = data.Koltuk; // Pop-up penceresini gösterme popup.style.display = 'block'; }) .catch(error => { console.error('API isteği sırasında bir hata oluştu:', error); }); }); }); // Pop-up penceresini kapatma olayı ekleme popupClose.addEventListener('click', function() { popup.style.display = 'none'; }); });