81,122
社区成员




<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>AJAX </title>
<script type="text/javascript">
var xmlHttpReq;
//创建XMLHTTP对象
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
var MSXML = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}else if(window.XMLHttpRequest){
xmlHttpReq = new XMLHttpRequest();
}
}
function change(){
createXMLHttpRequest();
var url = "test2.jsp?rand=" + Math.random();
xmlHttpReq.open("GET", url, true);
xmlHttpReq.onreadystatechange = callback;
xmlHttpReq.send(null);
}
function callback(){
if (xmlHttpReq.readyState == 4){
if (xmlHttpReq.status == 200){
document.getElementById("ajax").innerHTML = xmlHttpReq.responseText.replace(/\s*<\?/g, "<?");
}
}
}
function init(){
change();
setTimeout("init()",2000);
}
</script>
</head>
<body onload="init()">
<div id="ajax"></div>
</body>
</html>
<%@ page language="java" pageEncoding="GBK"%>
<%@ page contentType="text/html;charset=GBK" %>
<%
//连数据库
//取数据
//打印
%>