- Destek istenen forum
- https://localhost
Selamlar bir custom page oluşturuyorum aşağıdaki kodları kullanarak:
Bu kodu kullanarak bir sayfa oluşturuyorum ve sayfayı açtığım zaman sorunsuz fetch ediyor. herhangi bir problem yok.
Ama bu sayfayı bir butona overlay eklediğimde ve sayfayı overlay açtığımda dataları çekmiyor. yardımcı olursanız çok sevinirim.
Kod:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.1/css/dataTables.bootstrap5.min.css">
<section style="text-align: -webkit-center;">
<!-- table area -->
<table id="data" class="table table-striped" style="width:50%">
<thead>
<tr>
<th class="text-xs font-medium leading-4 tracking-wider text-left uppercase">NAME</th>
<th class="text-xs font-medium leading-4 tracking-wider text-left uppercase">LASTNAME</th>
<th class="text-xs font-medium leading-4 tracking-wider text-left uppercase">GENDER</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200 data">
</tbody>
</table>
</section>
<!-- js library -->
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.1/js/dataTables.bootstrap5.min.js"></script>
<script>
$.getJSON ("https://dummyjson.com/users", { mode: 'cors'})
.then(data=>{
console.log('data',data);
displayProducts(data.users);
})
async function displayProducts(products) {
let html = '';
await products.forEach((product, index, array) => {
html += '<tr>';
html += `
<td>${product.firstName}</td>
<td>${product.lastName}</td>
<td>${product.gender}</td>
`;
html += '</tr>';
})
document.querySelector('.data').innerHTML = await html;
//
$(document).ready(function () {
$('#data').DataTable();
});
}
</script>
Bu kodu kullanarak bir sayfa oluşturuyorum ve sayfayı açtığım zaman sorunsuz fetch ediyor. herhangi bir problem yok.
Ama bu sayfayı bir butona overlay eklediğimde ve sayfayı overlay açtığımda dataları çekmiyor. yardımcı olursanız çok sevinirim.