addition API BV
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<!doctype html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Schemi Liberi</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 20px;
|
||||
}
|
||||
#schemiList {
|
||||
margin-top: 10px;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
margin: 5px 0;
|
||||
}
|
||||
.error {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Elenco Schemi Liberi</h1>
|
||||
<div id="schemiList"></div>
|
||||
|
||||
<script>
|
||||
fetch("schemi_liberi.php")
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
return response.text().then((text) => {
|
||||
throw new Error(
|
||||
`Errore HTTP! Stato: ${response.status}, Risposta: ${text}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then((text) => {
|
||||
console.log("Risposta raw:", text);
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(text);
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
"Risposta non valida: " + text.substring(0, 100),
|
||||
);
|
||||
}
|
||||
const schemiList = document.getElementById("schemiList");
|
||||
if (data && data.value && Array.isArray(data.value)) {
|
||||
let html = "<ul>";
|
||||
data.value.forEach((schema) => {
|
||||
html += `<li>${schema.NomeSchema || "Nome non disponibile"}</li>`;
|
||||
});
|
||||
html += "</ul>";
|
||||
schemiList.innerHTML = html;
|
||||
} else if (data && data.error) {
|
||||
schemiList.innerHTML = `<p class="error">Errore: ${data.error}</p>`;
|
||||
} else {
|
||||
schemiList.innerHTML =
|
||||
"<p>Nessuno schema trovato o risposta non valida.</p>";
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Dettagli errore:", error);
|
||||
document.getElementById("schemiList").innerHTML =
|
||||
'<p class="error">Errore nel caricamento degli schemi: ' +
|
||||
error.message +
|
||||
"</p>";
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user