Javascript 如何通过ajax从php接收unicode字符串
我需要为我的项目接收来自php的unicode字符串,我想到的最好的方法是使用ajaxJavascript 如何通过ajax从php接收unicode字符串,javascript,php,ajax,Javascript,Php,Ajax,我需要为我的项目接收来自php的unicode字符串,我想到的最好的方法是使用ajax $.ajax({ url: './php_page.php', data: 'action=get_sum_of_records&code='+code, datatype: 'json', type: 'post', success: function(result){
$.ajax({
url: './php_page.php',
data: 'action=get_sum_of_records&code='+code,
datatype: 'json',
type: 'post',
success: function(result){
$('#block').html(result);
}
});
在php_page.php页面中:
echo '<table id="records" >';
echo '<tr>';
echo '<th>تاربخ</th>';
echo '<th>نوع</th>';
echo '<th>مبلغ</th>';
echo '<th>حذف</th>';
echo '</tr>';
echo '</table>';
echo';
回声';
回音“تاب㶦㶒”;
回音“نوع”;
回音“مبلغ”;
回音“حذف”;
回声';
回声';
但可悲的结果是:�����
我在ajax中使用了meta标记、contenttype等。。。jQuery文档中没有任何内容:
contentType Default: 'application/x-www-form-urlencoded; charset=UTF-8'
向服务器发送数据时,请使用此内容类型。默认为
“application/x-www-form-urlencoded;charset=UTF-8”,适用于
大多数情况下。如果显式地将内容类型传递给$.ajax(),则
它将始终发送到服务器(即使没有发送数据)。如果没有
如果指定了字符集,数据将使用
服务器的默认字符集;您必须在计算机上对其进行适当解码
服务器端
同时检查您的文件类型。如果您使用的是数据库,则必须将其保存在
utf8
编码中,而表列必须utf8
编码。您需要确保整个管道是utf-8。e、 g.即使您的php脚本正确地吐出了正确的字符集/内容类型等,您的.ajax()
转储到的页面也必须是utf8。我不敢相信我这么做了,可能是重复的,谢谢提醒……)