JQuery的ajax的用法在asp中使用$.ajax()實(shí)現(xiàn)
更新時(shí)間:2013年01月31日 15:56:37 作者:
ajax的出現(xiàn)解決了很多的疑難問(wèn)題,同時(shí)帶來(lái)了很多的方便,本文講述一下JQuery的ajax的用法在asp中使用$.ajax()來(lái)表示,感興趣的朋友可以了解下,或許本文對(duì)你有所幫助
復(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>無(wú)標(biāo)題文檔</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="請(qǐng)選擇"></option>
</select>
<input type="button" id="btn1" name="btn1" value="加載老師">
<!--<input type="submit" value="提交">-->
</form>
</body>
</html>
相關(guān)文章
用Promise解決多個(gè)異步Ajax請(qǐng)求導(dǎo)致的代碼嵌套問(wèn)題(完美解決方案)
這篇文章主要介紹了用Promise解決多個(gè)異步Ajax請(qǐng)求導(dǎo)致的代碼嵌套問(wèn)題(完美解決方案),需要的朋友可以參考下2017-02-02AJAX初體驗(yàn)之實(shí)戰(zhàn)篇——打造博客無(wú)刷新搜索
AJAX初體驗(yàn)之實(shí)戰(zhàn)篇——打造博客無(wú)刷新搜索...2006-08-08Ajax 配合node js multer 實(shí)現(xiàn)文件上傳功能
這篇文章主要介紹了Ajax 配合node js multer 實(shí)現(xiàn)文件上傳功能,需要的朋友可以參考下2017-08-08ajax實(shí)時(shí)任務(wù)提示功能的實(shí)現(xiàn)代碼
本項(xiàng)目運(yùn)用了 FLEAPHP,MYSQL,SMARTY,FCKEDItor,JSON,PROTOTYPE的技術(shù),在這里首先要感謝這些開(kāi)源項(xiàng)目的開(kāi)發(fā)者給我們帶來(lái)的好東西,其次要感謝[生氣豬--讓我?guī)退鲆粋€(gè)這樣的小東西來(lái)提醒她按時(shí)完成事情].花了一個(gè)3個(gè)小時(shí)完成.希望給大家起到拋磚引玉的作用啊....2008-09-09Ajax實(shí)現(xiàn)表格中信息不刷新頁(yè)面進(jìn)行更新數(shù)據(jù)
這篇文章主要為大家詳細(xì)介紹了Ajax實(shí)現(xiàn)表格中的信息不刷新頁(yè)面進(jìn)行更新數(shù)據(jù),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-10-10淺析JSONP解決Ajax跨域訪問(wèn)問(wèn)題的思路詳解
JSONP是一種使用JSON數(shù)據(jù)的方式,返回的不是JSON對(duì)象,是包含JSON對(duì)象的javaScript腳本。接下來(lái)通過(guò)本文給大家介紹jsonp解決ajax跨域訪問(wèn)問(wèn)題的思路,非常不錯(cuò)具有參考借鑒價(jià)值,感興趣的朋友一起看下吧2016-05-05