前端之家收集整理的这篇文章主要介绍了
使用ajax实现动态局部刷新,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<span style=
"font-size: medium;"
>refresh.jsp
<%@ page contentType=
"text/html;charset=UTF-8"
language=
"java"
%>
<head><Meta http-equiv=Content-Type content=
"text/html; charset=UTF-8"
></head>
<script language=
"javascript"
>
var XMLHttpReq;
function createXMLHttpRequest() {
if
(window.XMLHttpRequest) {
XMLHttpReq =
new
XMLHttpRequest();
}
else
if
(window.ActiveXObject) {
try
{
XMLHttpReq =
new
ActiveXObject(
"Msxml2.XMLHTTP"
);
}
catch
(e){
try
{
XMLHttpReq =
new
ActiveXObject(
"Microsoft.XMLHTTP"
);
}
catch
(e) {
}
}
}
}
function sendRequest() {
createXMLHttpRequest();
var url =
"refresh.do"
;
XMLHttpReq.open(
"POST"
,url,
true
);
XMLHttpReq.onreadystatechange = processResponse;
XMLHttpReq.send(
null
);
@H_696_
301@
}
function processResponse() {
if
(XMLHttpReq.readyState ==
4
) {
if
(XMLHttpReq.status ==
200
) {
DisplayHot();
setTimeout(
"sendRequest()"
,
1000
);
}
else
{
window.alert(
"您所请求的页面有异常。"
);
}
}
@H_615_
403@
}