求助ajax中文乱码~ 20
<html><head><metahttp-equiv="content-type"content="text/html;charset=gb2312"/><title>...
<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>
ajaxtext.asp如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Response.charset="GB2312"
dim reg
reg = Request.QueryString("regcode")
Response.write "王先生和他的朋友"®
%>
要求是在不改变GB2312编码的情况下,以GET方式提交,如何解决乱码~~
贴出详细代码有追分加!!! 展开
<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>
ajaxtext.asp如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Response.charset="GB2312"
dim reg
reg = Request.QueryString("regcode")
Response.write "王先生和他的朋友"®
%>
要求是在不改变GB2312编码的情况下,以GET方式提交,如何解决乱码~~
贴出详细代码有追分加!!! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询