My current issue involves using an ajax request to send a value from the client-side to the server-side in order to update a MySQL database. The specific challenge arises when dealing with text in Hindi language (हिन्दी मतलब जाने). When I alert the text on the client-side, it displays correctly as shown above, but after processing the server-side request, it gets inserted into the database like this: à ¤¹à ¤¿à ¤Âनà ¥Ââ?¬ à ¤®à ¤¤... However, if I use JavaScript to alert request.responseText
, it shows the correct text as हिन्दी मतलब जाने. Subsequently, upon reloading the page, the previously updated value appears incorrectly as ¤Â¹Ã ¤¿à ¤Âनà ¥Ââ?¬ à ¤®à ¤Âत..., while values that were not updated continue to display correctly as हिन्दी मतलब जाने.
In my client-side code, I have included:
var requestDatah = "values=" +
escape(valued) +"&texts=" +
encodeURIComponent(texted);
request1h[k].setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8;");
request1h[k].send(requestDatah);
And for the server-side handling, I'm setting the PHP header like this:
<?php header("Content-Type: text/html; charset=utf-8");
mysqli_set_charset($con,"utf8");
I am seeking assistance on how to rectify this issue and ensure proper storage and display of the Hindi text in the MySQL database.