如何通过ajax从php接收unicode字符串


how to receive unicode string from php through ajax

我需要为我的项目从php接收unicode字符串,我想到的最好的方法是使用ajax。

    $.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>';

但遗憾的是,结果是:�����

我在ajax中使用了元标签、内容类型等……没有

来自jQuery文档:

contentType Default: 'application/x-www-form-urlencoded; charset=UTF-8'

向服务器发送数据时,请使用此内容类型。默认值为"application/x-www-form-urlencoded;charset=UTF-8",对于大多数情况下。如果将内容类型显式传递给$.ajax(),则它将始终发送到服务器(即使没有发送数据)。如果没有如果指定了charset,则数据将使用服务器的默认字符集;您必须在服务器端。

还要检查您的文件类型,它必须以utf8编码保存,如果您使用的是数据库,则表列必须是utf8编码。