JS+html代码如下:
<script type="text/javascript" src="../Scripts/jquery-1.11.1.js"></script>
<script type="text/javascript">
<!--
$(function(){
$('#send').click(function(){
$.ajax({
type: "GET",
url: "Ajax/getClass.asp",
data: "depid=6",
dataType: "text",
success: function(data){
$('#resText').empty(); //清空resText里面的所有内容
var html = data;
$('#resText').html(html);
}
});
});
});
//-->
</script>
<div id="resText"><h2>Let AJAX change this text</h2></div>
<button id="send" type="button">Change Content</button>
GET方式传递text类型的变量,多个变量以“&”分割
getClass.asp代码如下:
<!-- #include file="../../inc/conn.asp" -->
<%
sql="SELECT * from classinfo where depid="&request("depid")&" and flag=1"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open sql, conn
'response.write sql
Response.CharSet = "GB2312"
If Not rs.eof Then
%>
班级: <select name="listClass" id="listClass">
<option value="0">--请选择--</option>
<%
do while not rs.eof
%>
<option value="<%=rs("id")%>"><%=rs("class")%></option>
<%
rs.movenext
loop
%>
</select>
<%
Else
%>
班级: <select name="listClass" id="listClass">
<option value="0">--请选择--</option>
</select>
<%
End If
rs.close
set rs = nothing
conn.close
set conn = nothing
%>