Home  >  Article  >  Backend Development  >  post乱码有关问题

post乱码有关问题

WBOY
WBOYOriginal
2016-06-13 11:19:13982browse

post乱码问题
用AJAX POST方法传递到位save.php,save.php内容如下:
uXH=2302044520120101&uXM=临时工&uXMPY=ls&uCYM=&uRXNY=&uNJ=&uBH=&uXSLBM=&uSFZH=&uXBM=&uXXM=&uCSRQ=&uCSDM=&uJGM=&uMZM=&uZJXY=&uGATQM=&uJKZKM=&uZZMMM=&uXZZ=&uHKSZD=&uHKXZM=&uLDRKZK=&uGBM=&uTC=&uLXDH=&uTXDZ=&uYZBM=&uDZXX=&uZYDZ=&uZP=&c_input_file=学生基本信息类&c_cxtj=username="bbb"
save.php内容如下:
session_start();
header('Content-Type:text/html;charset=GB2312'); 
include "conn.php";
//确定查寻文件
@$b_input_file= $_POST['c_input_file'];
//确定查寻条件
@$b_cxtj=$_POST['c_cxtj'];
//选择表或视图
$b_sql="SELECT * FROM t_menu where name=".$b_input_file;
 echo $b_input_file."    |    ".$b_cxtj."    |    ".$b_sql."
";
 echo $_POST['uXMPY'];
?>
可是用document.getElementById("nr").innerHTML=myxmlhttp.responseText ;
得到的却是:
“瀛︾敓鍩烘湰淇伅绫? | username="bbb" | SELECT * FROM t_menu where name=瀛︾敓鍩烘湰淇伅绫?ls”
是传递的是乱码还是取加的是乱码啊。
如何解决这个问题,谢谢。


------解决方案--------------------
转下编码
iconv("gbk","utf-8",$_POST['XX'])
------解决方案--------------------
由于你使用的是 gb2312 页面
ajax 端需用 encodeURIComponent 函数编码中文参数串
接收后用 iconv 函数转成你需要的编码
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn