当我将信息传递给 html 中的 div 时,无法识别 charset utf 8 并且它在文本中带有询问点。有没有办法强制 jquery 中的字符集 utf 8 使脚本传递的所有文本都以正确的字符集出现?
编辑:我想我可以在所有文件中设置所有字符集:HTML
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type:application/json; charset=UTF-8" />
<script type="text/javascript" src="scripts/jquery-1.9.0.min.js" charset="utf-8"></script>
<script type="text/javascript" src="message_validator.js" charset="utf-8"></script>
</head>
<body>
<div class="error_display" charset="utf-8"></div>
<form charset="utf-8">
<input type="text" id="name" class="textbox" name="name" minlength="2" maxlength="12" />
</form>
</body>
查询
$(document).ready(function() {
$(document).load("Content-Type:application/json; charset=UTF-8");
$('.submit').click(function(){
var errorlist = [];
errorlist.length = 0;
errorlist.push("- Tem de preencher os campos obrigatórios.");
if(errorlist.length >= 1){
$('.error_display').animate({'height':errorlist.length*20}, {queue:false, duration:500});
for(var i = 0; i < errorlist.length; i++) {
$('.error_display').append(errorlist[i]+"<br/>");
}
}
});
});