jQuery.ajax中.html里面的汉字显示不了?
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>demo</title>
<style>
body,input,label,select,p,h1,button{
font-size:30px;
line-height:1.8;
}
</style>
</head>
<body>
<h1>员工查询</h1>
<label>请输入员工编号:</label>
<input type="text" id="keyword"/>
<button id="search">查询</button>
<p id="searchResult"></p>
<h1>员工新建</h1>
<label>请输入员工姓名:</label>
<input type="text" id="staffName"/><br>
<label>请输入员工编号:</label>
<input type="text" id="staffNumber"/><br>
<label>请选择员工性别:</label>
<select id="staffSex">
<option>男</option>
<option>女</option>
</select><br>
<label>请输入员工职位:</label>
<input type="text" id="staffJob"/><br>
<button id="save">保存</button>
<p id="createResult"></p>
<script src="http://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"></script>
<script>
//发送查询请求并处理
$(document).ready(function() {
$("#search").click(function(){
$.ajax({
type: "GET",
url: "server.php?number="+$("#keyword").val(),
dataType: "json",
success: function(data){
if(data.success){
$("#searchResult").html(data.msg);
}else{
$("#searchResult").html("出现错误:" + data.msg);
}
},
error: function(jqXHR){
alert("参数错误"+jqXHR.status);
},
});
});
$("#save").click(function(){
$.ajax({
type: "POST",
url: "server.php",
data: {
name:$("#staffName").val(),
number:$("#staffNumber").val(),
sex:$("#staffSex").val(),
job:$("#staffJob").val()
},
dataType: "json",
success: function(data){
if(data.success){
$("#createResult").html(data.msg);
}else{
$("#createResult").html("出现错误:"+data.msg);
}
},
error: function(jqXHR){
alert("参数错误"+jqXHR.status);
},
});
});
});
</script>
</body>
</html>如上: “出现错误:”这几个字不显示,data.msg信息却可以显示。控制台没有报错。