请问为什么使用XMLHTTP请求用innerHTML方式添加到中的中文会显示出乱码?
swans 2002-10-28 10:44:40 请问为什么使用XMLHTTP请求用innerHTML方式添加到<span></span>中的中文会显示出乱码?
两个页面如下
============index.htm============
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function getFileList(mlbh,PageNo)
/*获取文件列表
{
FileList.innerHTML="LOADING...";
var xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
xmlhttp.Open("get", "ShowFile.asp?mlbh="+mlbh+"&PageNo="+PageNo,false);
xmlhttp.Send();
FileList.innerHTML=xmlhttp.responseText; //这里inner到span中的中文是乱码,请问何故?
xmlhttp=null;
return false;
}
</script>
</head>
<body>
<input type="button" name="button1" value="显示数据" onclick="getFileList(1234444,1);">
<span id="FileList"></span>
</body>
</html>
==========ShowFile.asp=======================
<%@CodePage="936"%>
<%
……
Response.ContentType="text/html"
Response.CharSet="gb2312"
……
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="BUTTONFACE">
<tr>
<td width="40%" class="title">文件名称</td>
<td width="18%" align="right" class="title">文件大小</td>
<td width="11%" align="center" class="title">上传人</td>
<td width="26%" align="center" class="title">上传时间</td>
<td width="5%" class="title"> </td>
</tr><%
Dim x
For x=1 to PageSize
%>
<tr bgcolor="#FFFFFF" height="20">
<td><%if qxlx>=0 then%><a href="#" onClick="DownLoad('<%=rootPath & trim(Rs("wjljdz"))%>');"><%=Trim(Rs("wjmc"))%></a><%else%><%=trim(Rs("wjmc"))%><%end if%></td>
<td align="right"><%=trim(Rs("wh"))%></td>
<td align="center"><%=trim(Rs("scr"))%></td>
<td align="center"><%=trim(Rs("scsj"))%></td>
<td align="center"><%if qxlx>=2 then%><input name="id" type="checkbox" id="id" value="<%=Rs("only_id")%>"><%end if%></td>
</tr><%
Rs.MoveNext
Next
Rs.close
set Rs=nothing
%>
</table>
==========end========