JQuery的ajax的用法在asp中使用$.ajax()實現(xiàn)
更新時間:2013年01月31日 15:56:37 作者:
ajax的出現(xiàn)解決了很多的疑難問題,同時帶來了很多的方便,本文講述一下JQuery的ajax的用法在asp中使用$.ajax()來表示,感興趣的朋友可以了解下,或許本文對你有所幫助
復(fù)制代碼 代碼如下:
<%
response.Expires=-1
response.CacheControl="no-cache"
%>
<!--#include file="../../conn/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
%>
復(fù)制代碼 代碼如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</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="請選擇"></option>
</select>
<input type="button" id="btn1" name="btn1" value="加載老師">
<!--<input type="submit" value="提交">-->
</form>
</body>
</html>
相關(guān)文章
用Promise解決多個異步Ajax請求導(dǎo)致的代碼嵌套問題(完美解決方案)
這篇文章主要介紹了用Promise解決多個異步Ajax請求導(dǎo)致的代碼嵌套問題(完美解決方案),需要的朋友可以參考下2017-02-02Ajax 配合node js multer 實現(xiàn)文件上傳功能
這篇文章主要介紹了Ajax 配合node js multer 實現(xiàn)文件上傳功能,需要的朋友可以參考下2017-08-08Ajax實現(xiàn)表格中信息不刷新頁面進行更新數(shù)據(jù)
這篇文章主要為大家詳細介紹了Ajax實現(xiàn)表格中的信息不刷新頁面進行更新數(shù)據(jù),具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-10-10