Hallo zusammen,
ich benutze fetch um diese PHP-Datei (listen_aus_db_laden.php) aufzurufen. Das hat auch bis ich heute ein Windows_update gemacht habe und den Rechner neugestartet habe, funktioniert. Jetzt erhalte ich aber folgende Fehlermldung:
app1.js:179 Fetch API cannot load file:///D:/xampp/htdocs/supertramp/localhost/supertramp/listen_aus_db_laden.php. URL scheme must be "http" or "https" for CORS request.
fetchData @ app1.js:179
loadOption @ app1.js:173
(anonymous) @ app1.js:157
app1.js:179 Fetch API cannot load file:///D:/xampp/htdocs/supertramp/localhost/supertramp/listen_aus_db_laden.php. URL scheme must be "http" or "https" for CORS request.
fetchData @ app1.js:179
loadItems @ app1.js:162
(anonymous) @ app1.js:158
app1.js:179 Uncaught (in promise) TypeError: Failed to fetch
at fetchData (app1.js:179)
at loadOption (app1.js:173)
at app1.js:157
fetchData @ app1.js:179
loadOption @ app1.js:173
(anonymous) @ app1.js:157
Promise.then (async)
fetchData @ app1.js:181
loadOption @ app1.js:173
(anonymous) @ app1.js:157
app1.js:179 Uncaught (in promise) TypeError: Failed to fetch
at fetchData (app1.js:179)
at loadItems (app1.js:162)
at app1.js:158
fetchData @ app1.js:179
loadItems @ app1.js:162
(anonymous) @ app1.js:158
Promise.then (async)
fetchData @ app1.js:181
loadItems @ app1.js:162
(anonymous) @ app1.js:158
VM139:1 Uncaught SyntaxError: Unexpected token h in JSON at position 0
at JSON.parse (<anonymous>)
at window.onload (app1.js:206)
Ich benutze xampp und habe alle Datein die ich aufrufe in dem Ordner Supertramp:
D:\xampp\htdocs\supertramp:
Ich habe bereits versucht, , die Datei mit localhost/supertramp/listen_aus_db_laden.php zu laden.
Hier der relevante Code.:
Vielen Dank für mögliche Vorschläge und Lösungsansätze.
function fetchData() {
fetch('listen_aus_db_laden.php').then(function (rep) {
return rep.json()
}).then(function (data) {
//console.log(data);
let result = data
result2= JSON.stringify(result);
output1.textContent = result2;
trips= output1.textContent;
trips= JSON.parse(trips);
})
};