ajax学习相关的好网址

http://www.wujianrong.com/archives/2007/05/20jspajax.html      简单用例
http://www.ibm.com/developerworks/cn/web/wa-ajaxintro/          IBM—Ajax讲解
http://www.w3schools.com/ajax/ajax_example.asp                     Ajax—Example  W3CSchol



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
">

<html>
<head>
<script src="ajax. js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page using AJAX</title>
</head>
<body>

<a onclick="sendRequest('GET','index.jsp')" href="#">Server Date Time:</a>
<div id="ajax_res">Server Date Time will replace this text.</div>
</body>
</html>

index.jsp
<html>
<body>
<%=new java.util.Date()%>
</body>
</html>

ajax. js
function createRequestObject(){
var req;
if(window.XMLHttpRequest){
//For Firefox, Safari, Opera
req = new XMLHttpRequest();
}
else if(window.ActiveXObject){
//For IE 5+
req = new ActiveXObject("Microsoft.XMLHTTP");
}
else{
//Error for an old browser
alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
}

return req;
}

//Make the XMLHttpRequest Object
var http = createRequestObject();

function sendRequest(method, url){
if(method == 'get' || method == 'GET'){
http.open(method,url);
http.onreadystatechange = handleResponse;
http.send(null);
}
}

function handleResponse(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response){
document.getElementById("ajax_res").innerHTML = response;
}
}
}
run this application may be u get some clue

你可能感兴趣的:(ajax学习相关的好网址)