ASP+ACCESS数据库二级联动Ajax返回数据IE下乱码问题
附上所有文件代码,找了好多天真心不知道哪里出了问题,在谷歌浏览器下是正常的,但是在IE下在第二级菜单option就是乱码口口口那种东西了....求高手解决啊。。代码要怎么修改
index.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>成绩查询</title>
<script language="javascript" type="text/javascript" src="Ajax.js"></script>
</head>
<body>
<br />
<form name="myform" action="result.asp" method="post">
<select name="BId" onChange="getoId(this.value,'');">
<option value="">选择课程性质</option>
<%
Dim oRs,oSQL
Set oRs = server.CreateObject("adodb.recordset")
oSQL = "Select * From score Where oId = 0 Order by id asc"
oRs.Open oSQL,Conn,1,1
If (oRs.EOF And oRs.BOF) Then
Response.Write("<option value="""">选择课程性质</option>")
Else
Do While Not oRs.EOF
Response.Write("<option value="""&oRs(0)&""">"&oRs(1)&"</option>")
oRs.MoveNext
Loop
End If
oRs.Close:Set oRs = Nothing
%>
</select>
<span id="SmClass"></span>
<input name="" type="submit" value="查询"/>
</form>
</body>
</html>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>成绩查询</title>
<script language="javascript" type="text/javascript" src="Ajax.js"></script>
<link href="../css/result.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br />
<form name="myform" action="result.asp" method="post">
<select name="BId" onChange="getoId(this.value,'');">
<option value="">请选择课程性质</option>
<%
Dim oRs,oSQL
Set oRs = server.CreateObject("adodb.recordset")
oSQL = "Select * From score Where oId = 0 Order by id asc"
oRs.Open oSQL,Conn,1,1
If (oRs.EOF And oRs.BOF) Then
Response.Write("<option value="""">请选择课程性质</option>")
Else
Do While Not oRs.EOF
Response.Write("<option value="""&oRs(0)&""">"&oRs(1)&"</option>")
oRs.MoveNext
Loop
End If
oRs.Close:Set oRs = Nothing
%>
</select>
<span id="SmClass"></span>
<input name="" type="submit" value="查询"/>
</form>
<%
Score = Request.Form("Score")
Response.Write("<div class=""score_title"">")
Response.Write("所查课程的成绩:</div>")
Response.Write("<div class=""score_value"">")
Response.Write("<span style=""font-size:200px"">")
Response.Write(""&Score&"</span>分</div>")
%>
</body>
</html>
------------------------------------------------
conn.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Dim Mdb,Conn,ConnStr
Mdb="../db/db.mdb"
Set Conn = Server.CreateObject("ADODB.Connection")
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(Mdb) & " "
Conn.open ConnStr
Sub CloseConn()
If IsObject(Conn) Then
Conn.Close
Set Conn = Nothing
End If
End Sub
%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>成绩查询</title>
</head>
<body>
<%
Dim outStr,oRs,oSQL
oId = Request("oId")
sId = Request("sId")
If (oId = "" Or IsNull(oId)) Then
outStr = ""
Else
outStr = "<select name=""Score"">"
outStr = outStr &"<option value=""0"">请选择课程名称</option>"
oSQL = "Select * From score Where oId = "&oId&" "
oSQL = oSQL &" Order by id asc"
Set oRs = Conn.Execute(oSQL)
If (oRs.EOF And oRs.BOF) Then
outStr = outStr &"<option value=""0"">请选择课程名称</option>"
Else
Do While Not oRs.EOF
If Trim(sId) = Trim(oRs(0)) Then
outStr = outStr &"<option value="""&oRs(3)&""" selected>"&oRs(1)&"</option>"
Else
outStr = outStr &"<option value="""&oRs(3)&""">"&oRs(1)&"</option>"
End If
oRs.MoveNext
Loop
End If
outStr = outStr &"</select>"
Set oRs = Nothing
End If
Response.Write(outStr)
%>
</body>
</html>
function CreateAjax(){
var XMLHttp;
try
{
XMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); //IE的创建方式
}
catch(e)
{
try
{
XMLHttp = new XMLHttpRequest(); //FF等浏览器的创建方式
}
catch(e)
{
XMLHttp = false; //创建失败,返回false
}
}
return XMLHttp; //返回XMLHttp实例
}
function getoId(ids,sId){
var xmlHttp = CreateAjax();
var urlLink = 'class.asp?oId='+ids+'&sId='+sId+'&n='+Math.random()+'';
if(xmlHttp){
xmlHttp.open('GET',urlLink,true);
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4){//客户端完成请求
if(xmlHttp.status == 200){//服务端完成处理并返回数据
var ResponseText = xmlHttp.responseText;
if(ResponseText == ""){//service返回了错误信息
//alert("yes");
SmClass.innerHTML = ResponseText;
}else{
//alert("no");
SmClass.innerHTML = ResponseText;
}
}else{
SmClass.innerHTML = '服务器返回异常...';//服务器出现异常
}
}else{
SmClass.innerHTML = '正在加载数据...';//请求未完成时的提示信息
}
}
xmlHttp.send(null);//向服务器发送请求
}else{
SmClass.innerHTML = '您的浏览器不支持或未启用 XMLHttp!';//创建未成功
}
}
<!--#include file="conn.asp" -->
<%
Dim outStr,oRs,oSQL
oId = Request("oId")
sId = Request("sId")
If (oId = "" Or IsNull(oId)) Then
outStr = ""
Else
outStr = "<select name=""Score"">"
outStr = outStr &"<option value=""0"">请选择课程名称</option>"
oSQL = "Select * From score Where oId = "&oId&" "
oSQL = oSQL &" Order by id asc"
Set oRs = Conn.Execute(oSQL)
If (oRs.EOF And oRs.BOF) Then
outStr = outStr &"<option value=""0"">请选择课程名称</option>"
Else
Do While Not oRs.EOF
If Trim(sId) = Trim(oRs(0)) Then
outStr = outStr &"<option value="""&oRs(3)&""" selected>"&oRs(1)&"</option>"
Else
outStr = outStr &"<option value="""&oRs(3)&""">"&oRs(1)&"</option>"
End If
oRs.MoveNext
Loop
End If
outStr = outStr &"</select>"
Set oRs = Nothing
End If
Response.Write(outStr)
%>