关于PHP GET传参乱码的问题 本人用JQUERY的$.get()方法向指定页面传参数,可遇到中文就会乱码,不知道是什么回事?网上找了很多方法都不行,哪位大侠知道的,请指教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将参数 encodeURIComponent() 编码试试 encodeURIcomponent(string).replace(/%20/g, "+");得urlencode一下再放到URL里, 另外你的这个JQUERY的页面说明charset了吗,和GET的页面的编码一致吗。 一致的,都是<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />在哪里用encodeURIcomponent(string).replace(/%20/g, "+");呢? 把中文GET参数传给encodeURIcomponent(string).replace(/%20/g, "+")的string,结果拼接到Query部分。 php和html的文件编码格式一致吗 jquery代码是这样的: $.get('get.php', { name: bookcaseName }, function(data) { alert(unescape(data)); });PHP页面代码:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><?php $name=$_GET['name'];/*$name = iconv("gbk","utf-8",$name); */$name=mb_convert_encoding($name, "UTF-8", "gb2312");if($name=='123'){ echo 'username already exist!';}else{ echo escape($name); }?></body></html> html,php都搞成utf-8.html端,encodeURIComponent(bookcaseName )就可以了 在js或jquery中,使用escape 和unescape 解决乱码是常用的!都测试一下吧 换成 utf-8格式的,记住是所有的,而且是utf-8无BOM格式的 所有文件编码都换成utf-8的吧。。这样就减少很多问题了。 点击text文本框,内嵌input隐藏的问题 eclipse不能调试php的问题 一个函数调用方面的错误,求解。 PHP用header进行文件下载 请问 怎样实现按照原来输入的格式输出? 急,我的Mysql出现问题了啊!无法启动! 在线等待:请看代码,insert问题!!!急~~~ php安装的时候遇到问题(高手进) Date("Y-m-d H:i",$_GET['time']+8*60*60) 的问题 大牛快来领分了 紧急求助,安装php5.2.5+fpm后apache报错undefined symbol: event_set 运行php程序时FastCGI出现错误 请问如何解决
在哪里用encodeURIcomponent(string).replace(/%20/g, "+");呢?
把中文GET参数传给encodeURIcomponent(string).replace(/%20/g, "+")的string,结果拼接到Query部分。
$.get('get.php', { name: bookcaseName }, function(data) {
alert(unescape(data));
});
PHP页面代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<?php $name=$_GET['name'];
/*$name = iconv("gbk","utf-8",$name); */
$name=mb_convert_encoding($name, "UTF-8", "gb2312");if($name=='123')
{
echo 'username already exist!';}else{ echo escape($name);
}
?>
</body>
</html>
html端,encodeURIComponent(bookcaseName )就可以了