谁给个最简单的asp代码示例
刚解除asp,想玩一下asp的异步调用,照着别人的代码写了半天,调试不报错,就是不出想要的结果,郁闷中,谁能给我个简单的asp+ajax调用的示例。要求:1.需要连接access数据库
2.需要使用到ajax异步调用
代码越简单越好,最终实现的效果就是点一个按钮,从数据库里面捞一条数据,然后显示到页面上,利用ajax实现页面无刷新。
源代码最好发QQ邮箱 tianhewulei@qq.com,各位大侠万分感谢,最好在程序上多写点注释,asp语法相当不熟
补充:只要基本功能,数据库一张表,一个字段即可,页面一个按钮,一个显示结果的地方即可,各位大虾帮帮忙啊
答案:index.htm''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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=utf-8" />
<title>PROTOTYPE POST</title>
<script language="javascript" type="text/javascript" src="prototype.js"></script>
</head>
<body>
<script type="text/javascript">
function postNewContact(){
var form = $('form');
var name = $('uin');
var url = '2.asp';
var myAjax = new Ajax.Request(url,{method:'post',
parameters: Form.serialize(form),
onComplete:showResponse});
}
function showResponse(originalRequest){
DisplayDIV.innerHTML+=originalRequest.responseText;
}
</script>
<form method="post" id="form" name="form">
<input type="text" name="uin">
<input onclick="postNewContact();" name="pbut" type="button" value="POST" />
<div id="DisplayDIV"></div>
</form>
</body>
</html>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-------------------------------------------------
2.asp
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
<%
set conn=server.createobject("adodb.connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;User Id=admin;jet OleDB:Database Password=;Data Source="& Server.MapPath("/data.asp")
exec="select * from file where id = " +request("uin")
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
if rs.eof then
Response.write "Id Err!"
else
do while not rs.eof
%><%=rs("name")%><%
rs.movenext
loop
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%><br>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
上一个:织梦的程序有默认的防CC攻击功能吗
下一个:FSO生成TXT,求ASP代码