欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

簡(jiǎn)單的AJAX實(shí)現(xiàn)(HELLO AJAX)

 更新時(shí)間:2010年03月13日 12:05:07   作者:  
簡(jiǎn)單的AJAX實(shí)現(xiàn)(HELLO AJAX) ,實(shí)現(xiàn)代碼,主要是了解下,流程。
客戶端部分:
復(fù)制代碼 代碼如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html"/>
<script language="javascript">
var ajax;
function createAjax()
{
if(window.ActiveXObject)
{
try
{
return new ActiveXObject("Msxm12.XMLHTTP");
}
catch(e)
{
try
{
return new
ActiveXObject("Microsoft.XMLHTTP");
}
catch(e2)
{
return null;
}
}
}
else if(window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
else
{
return null;
}
}
function onRcvData()
{
if(ajax.readyState==4)
{
if(ajax.status==200)
{
var content=document.getElementById('content');
content.innerHTML=ajax.responseText;
}
else
{
alert("error");
}
}
}
function ajaxSendRequest(uri)
{
ajax=createAjax();
if(!ajax)
{
alert("no");
return 0;
}
ajax.onreadystatechange=onRcvData;
ajax.open("GET",uri,true);
ajax.send("");
}
</script>
<title>Hello AJAX</title>
</head>
<body>
<div id="content"></div>
<br>
<input type="button" value="Hello"
onclick="ajaxSendRequest('http://localhost:8080/test/hello.jsp')">
</body>
</html>

服務(wù)器端部分(hello.jsp)
復(fù)制代碼 代碼如下:

<html>
<head>
<title>hellp</title>
</head>
<body>
<%
out.println("HELLO AJAX");
%>
</body>
</html>

相關(guān)文章

最新評(píng)論