while ($row = $results->fetch_assoc()) {
$rows[] = array(
'id' => $row['id'],
'shipDataLastLocaltion' => $row['SDLLP']
);
}
print '{"data": ';
echo json_encode($rows, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
print "}";
$this->response('', 200);
Data in the table:
$row['SDLLP'] //-> "Istanbul’Beşiktaş"point:3""
Error screen:
SyntaxError: JSON.parse: unexpected character at line 1 column 10 of the JSON data
The reason for the error:
These characters are in the table "
and ’
JSON does not work because of these characters - I used this function for this, but it did not work.
I tried this for the solution htmlspecialchars
and other methods I found on the internet but all method did not work.
What could be the solution to this?