Fetch -API ist bei iOS Safari nicht erfolgreichJavaScript

Javascript-Forum
Anonymous
 Fetch -API ist bei iOS Safari nicht erfolgreich

Post by Anonymous »

Aus irgendeinem Grund funktioniert dies bei Android/Windows oder einem Gerät völlig in Ordnung, außer wenn versucht wird, es auf iOS/iPhone -Safari anzusehen. Die Daten werden nicht geladen. Ich habe sogar versucht und die API zu einer lokalen JSON -Datei gemacht, und sie wird sie trotzdem nicht lesen. < /P>
Was scheint das Problem zu sein? Ein Problem ist, dass ich keinen Mac habe, um das Problem zu diagnostizieren. Wie gehe ich dieses Problem mit iOS. Danke < /p>
async function loadQuranData() {
try {
// Load Quran text from API
const quranResponse = await fetch('https://api.alquran.cloud/v1/quran/quran-uthmani');
if (!quranResponse.ok) {
throw new Error(`Failed to load Quran data: ${quranResponse.status}`);
}
const quranJson = await quranResponse.json();

// Validate Quran data structure
if (!quranJson.data || !quranJson.data.surahs) {
throw new Error('Invalid Quran data format');
}

quranData = quranJson.data.surahs;

// Populate surah select immediately after loading Quran data
const select = document.getElementById('surahSelect');
if (!select) {
throw new Error('Surah select element not found');
}

// Clear existing options
select.innerHTML = '' + languages[currentLang].selectSurah + '';

// Create options for each surah
quranData.forEach((surah, index) => {
const option = document.createElement('option');
option.value = index;
option.textContent = `${surah.number}. ${surah.name}`;
select.appendChild(option);
});

// Remove any existing event listeners
const newSelect = select.cloneNode(true);
select.parentNode.replaceChild(newSelect, select);

// Add the event listener
newSelect.addEventListener('change', (e) => {
if (e.target.value !== '') {
currentSurah = parseInt(e.target.value);
currentAyah = 0;
isReadingMode = false;
document.getElementById('btnReadingMode').innerHTML = '';
displayAyah();
} else {
resetQuranContent();
}
});
< /code>
Versuchte 3 AI -Code -Bots, versuchte, die API in eine JSON -Datei zurückzugeben und sie manuell zu lesen und nicht zu tun. Danke

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post