Home > Backend Development > PHP Tutorial > ajax乱码有关问题(仿百度搜索页面),在线求解答,大侠们有空速度帮忙

ajax乱码有关问题(仿百度搜索页面),在线求解答,大侠们有空速度帮忙

WBOY
Release: 2016-06-13 12:38:35
Original
740 people have browsed it

ajax乱码问题(仿百度搜索页面),在线求解答,大侠们有空速度帮忙
  这种乱码如何解决!!!我代码都贴出来:

<?php<br />
//require('common.inc.php');<br />
//require('config.inc.php');<br />
mysql_connect('localhost', 'root' ,'123456');<br />
mysql_select_db("hxyjw_20100416");<br />
mysql_query("SET NAMES GBK");//防止数据库交互时乱码<br />
header('Content-Type:text/html;charset=gbk');<br />
<br />
$queryString = $_POST['queryString'] ;<br />
<br />
if(strlen($queryString) >0) {<br />
$sql= "SELECT username FROM phpcms_member WHERE username LIKE '".$queryString."%'  LIMIT 0,15";<br />
echo $sql;<br />
$query = mysql_query($sql);<br />
while ($result = mysql_fetch_array($query))<br />
{<br />
	$value=$result['username'];<br />
	echo '<li onClick="fill(\''.$value.'\');">'.$value.'</li>';<br />
}<br />
<br />
}<br />
?><br />
Copy after login


htm:

nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br>
<br>
<br>
<meta><br>
<title>Ajax搜索功能</title><br>
<script></script><br>
<script><br />
function lookup(inputString) {<br />
if(inputString.length == 0) {<br />
// Hide the suggestion box.<br />
$('#suggestions').hide();<br />
} else {<br />
$.post("rpc.php", {queryString: ""+inputString+""}, function(data){<br />
if(data.length >0) {<br />
$('#suggestions').show();<br />
$('#autoSuggestionsList').html(data);<br />
}<br />
});<br />
}<br />
} // lookup<br />
function fill(thisValue) {<br />
$('#inputString').val(thisValue);<br />
setTimeout("$('#suggestions').hide();", 200);<br />
}<br />
</script><br>
<style><br />
body {<br />
font-family: Helvetica;<br />
font-size: 11px;<br />
color: #000;<br />
}<br />
h3 {<br />
margin: 0px;<br />
padding: 0px;<br />
}<br />
.suggestionsBox {<br />
position: relative;<br />
left: 30px;<br />
margin: 10px 0px 0px 0px;<br />
width: 200px;<br />
background-color: #212427;<br />
-moz-border-radius: 7px;<br />
-webkit-border-radius: 7px;<br />
border: 2px solid #000;<br />
color: #fff;<br />
}<br />
.suggestionList {<br />
margin: 0px;<br />
padding: 0px;<br />
}<br />
.suggestionList li {<br />
margin: 0px 0px 3px 0px;<br />
padding: 3px;<br />
cursor: pointer; <div class="clear">
                 
              
              
        
            </style>
Copy after login
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template