<script language="javascript" type="text/javascript">
var xmlHttp = false;
/* Create a new XMLHttpRequest object to talk to the Web server */
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function a()
{
// Get the city and state from the web form
// Build the URL to connect to
var url = "tj.asp?id=1";
// Open a connection to the server
xmlHttp.open("GET", url, true);
// Setup a function for the server to run when it's done
xmlHttp.onreadystatechange = update;
xmlHttp.send(null);
}
function update()
{
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById('count').innerHTML=response;
}
}
</script>
<body onLoad="a();">
<input type="button" onClick="a()" />
<span id="count">载入中...</span>
</body>
tj.asp
<%
conn.execute("update tj set count=count+1 where id="&int(request("id")))
set rs=conn.execute("select count from tj where id="&int(request("id")))
sleep(500)
response.Write rs("count")
%>