我有一个复选框,可以在单击时更改表格的内容。
出于某种原因,我在使用ajax提交表单后,我的UTF-8不再有效。
的Ajax:
function showUser() {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("table").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?customer="+variable);
xmlhttp.send();
}
和getuser.php:
$customer = intval($_GET['customer']);
$connection = mysqli_connect('localhost','root','*********','name');
if (!$connection) {
die("Could not connect: " . mysqli_error($connection));
}
if($customer == 1) {
$searchType= 1;
} else {
$searchType= 0;
}
$sql="SELECT * FROM table WHERE type= $searchType";
$result = mysqli_query($connection,$sql);
在此之后,我回显一个包含从数据库获取的内容的表。在我的数据库中,有些客户的名字中有一些特殊字符。它只显示?而不是像往常一样显示它们?代替那些特殊的角色。
有任何帮助吗? (我的英语不好)