求助ajax中文乱码

yongsky 2009-08-08 03:46:16
都指定了编码格式怎么还出现乱码???

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>ajax</title>
<script type="text/javascript">
var xmlHttp;
function createXML(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}

function startXml(){
createXML();
xmlHttp.onreadystatechange = handleStateChange;
var newobj = document.getElementById("test").value;
var url="ajaxtext.asp?regcode="+newobj+"&cc"+Math.random();
xmlHttp.open("get",url,true);
xmlHttp.send(null);
}

function handleStateChange(){
if (xmlHttp.readyState == 4 && xmlHttp.status==200){
retext=xmlHttp.responseText;
document.getElementById("show").innerHTML = retext;

}
}
</script>
</head>
<body>
<input id="test" type="text" />
<button onclick="javascript:startXml();">see!</button><br />
<div id="show"></div>
</body>
</html>




<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Response.charset="GB2312"
dim reg
reg = Request.QueryString("regcode")
Response.write "王先生和他的朋友"®
%>
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yongsky 2009-08-08
  • 打赏
  • 举报
回复
除改utf-8外,有什么方法可以实现在gb2312编码情况下解决乱码的方法呢?
hookee 2009-08-08
  • 打赏
  • 举报
回复
编码改为UTF-8,文件本身的编码也要改为utf-8,可用windows记事本打开文件,然后另存为,选编码utf-8

<%
Response.charset="UTF-8"
dim reg
reg = Request.QueryString("regcode")
Response.write "王先生和他的朋友"®
%>

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧