I apologize if this question has been asked before, but I can't seem to get on of them to work for me. The PHP script passes database results to JavaScript like this:
$queryResult = mysqli_query($dbase, $query);
if ($queryResult) {
$result = array();
while($row = mysqli_fetch_array($queryResult)) {
$result[] = $row;
}
}
echo json_encode($result);
JavaScript then receives this through AJAX (result of console.log):
[{"id":"1","name":"Babe Ruth","loginID":"babe","loginPW":"babe123"}]
I've tried JSON.stringify, Object.keys(arr), foreach ($arr as $key => $value), for(i in arr), but all to no success.
How can I read this as key-value pairs?
TIA.