How to properly display Chinese characters in HTML through ajax using PHP?
In the MySQL I have this data èŠ±æ ·å¹´åŽ
, if I use PHP echo it shows 花样年华
, but if I use ajax callback I get èŠ±æ ·å¹´åŽ
(eventname), the ajax code is as below:
$.ajax({
url: "action/getEvent.php",
type: "POST",
data: {'LoadEvent':''},
dataType: "json",
success: function(data) {
if(data.eventname!=''){
alert(data.eventname);
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
}
});
Is it I need to do something on the data before saving into MySQL database? But why PHP is ok only ajax is not?