52,797
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","/ajax/",true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="myDiv"><h2>需要刷新的局部内容</h2></div>
<button type="button" onclick="loadXMLDoc()">通过 AJAX 实现局部刷新</button>
</body>
</html>
int websAjaxHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
char_t *url, char_t *path, char_t *query)
{
websHeader(wp);
websWrite(wp, T("<body><h2>this is ajax test!</h2>\n"));
websFooter(wp);
websDone(wp, 200);
return 1;
}