Hallo,
aus meiner html "Datenbanktabelle" sende ich verschiedene Befehle per fetch an PHP um die Datenbank zu ändern.
JS Fetch => PHP und wieder Bestätigung zurück PHP Rückmeldung => JS
Das JS Fetch an PHP funktioniert. Bei der Rückmeldung (PHP=>JS) bekomme ich nachfolgende Meldung im Firefox debugger.
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
function sendData(data)
{
fetch("datapointsEdit.php",
{
method: 'POST',
header: 'Content-Type: application/json; charset=UTF-8',
body: JSON.stringify(data),
})
.then(response => response.json())
.then(data => {
let x = data['Answer'];
alert ("Answer: " + x); })
.catch(function(err) { console.log("Error: ", err); });
}
Die Rückmeldung erzeuge ich mit PHP so.
$answer = array ('Answer' => 'saveDatapoint : OK');
echo json_encode($answer, JSON_PRETTY_PRINT);
Ich sehe den Fehler nicht ....
Vielen Dank !!!!