ajax问题。在线结贴。

WBOY
Release: 2016-06-23 14:00:36
Original
934 people have browsed it

我有个快速搜索功能。但是通过测试。发现 我输入到文本框的汉字。是乱码。之前曾经用过一个函数转换过 就好用了。但是又忘记是那个函数了。我把大概代码贴出来。大神们来帮帮我 。急

 快速搜索客户:    
Copy after login




Copy after login


回复讨论(解决方案)

我的userajax.php代码

connect($db_config); $sql = 'select id,true_name from users where user_type = 1 and true_name like "%'.$username.'%"'; //echo $sql;exit(); $rs = mysql_query($sql); $html = ''; echo $html;?>
Copy after login

先查看下你的页面的字符集编码,保持html页面与php的编码一致,应该是编码不一致导致的

先查看下你的页面的字符集编码,保持html页面与php的编码一致,应该是编码不一致导致的

检查过了。 都是gbk 。 我以前用过一个函数改好过。但是我忘记是那个函数了

string iconv ( string $in_charset , string $out_charset , string $str )

谢谢了 自己解决了

$_POST['username']=iconv("UTF-8","gbk",$_POST["username"]);
Copy after login


我把ajax这样处理就可以了

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!