In my setup, I have both an admin module and a front end module available.
Specifically, there is a category section that plays a key role in the functionality.
To create categories, I utilize AJAX to send data from a text box to PHP. It's important to note that both the admin and front end modules support utf-8 character encoding.
Typically, AJAX uses utf-8 encoding by default, which allows for successful saving of Unicode text in the database.
This Unicode text can be viewed in the database itself, as well as when listing items within both the admin and front end sections.
However,
An issue arises when attempting to edit existing data. When fetching this data using AJAX/JSON, instead of displaying the Unicode text properly, it returns as a series of question marks (????).
Oddly enough, during normal loading situations, the Unicode text displays correctly without any problems.
What could possibly be causing this discrepancy? Is there something I am overlooking?
Edit
var jax = createAjax();
jax.open("POST",path,true)
jax.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');
jax.onreadystatechange = afunction;
Provided above is the pertinent PHP code snippet:
$query = "select * from $box where id=$id";
if(! ($res = mysql_query($query)))die(mysql_error());
$rs = mysql_fetch_array($res,1);
$rs['status'] = 1;
header("Content-Type: text/html; charset=utf-8");
die(json_encode($rs));
I've made sure to use the same utf-8 encoding for both requests and responses, even experimenting with changing it to iso-85**-1 with no noticeable effect.
For visual reference, attached below are screenshots: Please open the images in a new window or tab for better viewing.
The first image showcases how the utf characters are displayed smoothly in the listings, while the second highlights the issue when editing via AJAX and JSON - resulting in the dreaded '???'.
Additionally, here's a glimpse of how the text appears within the database...