Home > Backend Development > PHP Tutorial > ajax有关问题。在线结贴

ajax有关问题。在线结贴

WBOY
Release: 2016-06-13 11:51:26
Original
799 people have browsed it

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

<br /><select name="suppler_id" style="width:100px;"><br />                                        <option value="0">选择供应商</option><br />                                        <?php foreach($suppler_option as $val){?><br />                                            <option value="<?php echo $val['id'];?>" <?php if(isset($suppler_id) && $suppler_id==$val['id']){echo 'selected="selected"';}?>><?php echo $val['true_name'];?></option><br />                                        <?php }?><br />                                    </select><br />									快速搜索客户:<br />									<input type="text" id="username" size="10px;"><br />									<span id="userdiv"><br />	                                    <select name="user_id" style="width:100px;"><br />	                                        <option value="0">选择客户</option><br />	                                        <?php foreach($user_option as $val){?><br />	                                            <option value="<?php echo $val['id'];?>" <?php if(isset($user_id) && $user_id==$val['id']){echo 'selected="selected"';}?>><?php echo $val['true_name'];?></option><br />	                                        <?php }?><br />	                                    </select><br />									</span><br />
Copy after login




<br /><script type="text/javascript"><br />$(document).ready(function () {<br />    $(function(){<br />        $("#username").live('keyup',function(){<br />			var username = $(this).val();<br />			if(username != ''){<br />				$.post('../userajax.php',{'username':username},function(msg){<br />                    $("#userdiv").html(msg)<br />                });<br />			}<br />		})<br />    })<br />});<br /></script> <br />
Copy after login

------解决方案--------------------
先查看下你的页面的字符集编码,保持html页面与php的编码一致,应该是编码不一致导致的
------解决方案--------------------
string iconv ( string $in_charset , string $out_charset , string $str )

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