Copy codeThe Code is as follows:
<%
Response. Expires =-1
Response. CacheControl = "no-cache"
%>
<! -- # Include file = ".../../conn. asp" -->
<! -- # Include file = "../psw. asp" -->
<! -- # Include file = ".../../functions/dofunction. asp" -->
<! -- # Include file = ".../../functions/showfunction. asp" -->
<! -- # Include file = ".../../fqdb/admin/website. asp" -->
<%
Cmd = checkstr (request ("cmd"), 2)
If cmd = "loadteacher" then
Response. Charset = "gb2312"
Set rs = server. CreateObject ("adodb. recordset ")
SQL = "select teacher_id, name from Edu_Person"
Rs. open SQL, conn, 1, 3
Response. write "{" "data "":["
I = 0
Do until rs. eof
I = I + 1
Response. write "{" "Id" ":" & rs ("teacher_id") & "," "Name": "& rs (" name ") &"""}"
If I <rs. recordcount then response. write ","
Rs. movenext ()
Loop
Response. write "]}"
Response. End ()
End if
%>
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
<Script type = "text/javascript" src = ".../js/common/jquery-1.8.0.min.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("# Btn1"). click (function (){
// Alert ("click ");
$. Ajax ({
Url: "ajaxtest. asp? Cmd = loadteacher ",
DataType: "json ",
Success: function (json ){
// Var odata = $. parseJSON (json );
Var data = json. data;
For (var I = 0, len = data. length; I <len; I ++ ){
Document. writeln (data [I]. Name );
}
}
});
});
});
</Script>
</Head>
<Body>
<Form id = "myform" method = "post" action = "ajaxtest. asp">
<! -- <Input type = "hidden" name = "cmd" value = "loadteacher"> -->
<Select id = "tearchers" name = "teachers">
<Option value = "select"> </option>
</Select>
<Input type = "button" id = "btn1" name = "btn1" value = "">
<! -- <Input type = "submit" value = "submit"> -->
</Form>
</Body>
</Html>