php ajax 中文乱码问题解决办法(接收发送)

View Code
 1 PHP发送中文、Ajax接收
2 只需在php顶部加入一句:
3 header('Content-type: text/html;charset=GB2312');
4 xmlHttp会正确解析其中的中文。
5
6 Ajax发送中文、PHP接收
7 这个比较复杂:
8 Ajax中先用encodeURIComponent对要提交的中文进行编码
9 PHP中:
10 $GB2312string=iconv( 'UTF-8', 'gb2312//IGNORE' , $RequestAjaxString);
11
12 PHP写入MySQL数据库
13 建立conn时,query一下set names "gb2312"
14
15 iconv( "UTF-8","GBK" , $gametypes["name"]);

原文地址:https://www.cnblogs.com/wsl2011/p/2195306.html