前台页面ceshi.htm
<script>
function getHTTPObject()
{
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E)
{
xmlhttp = false;
}
}
if (!xmlhttp && typeof
XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function update()
{
var xmlhttp=getHTTPObject();
var post="test·test+test·测试";
xmlhttp.open('POST',
'update.asp?random='+Math.random(), true);
xmlhttp.setrequestheader("content-length",post.length);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function()
{
if
(xmlhttp.readyState == 4 &&
xmlhttp.status == 200 )
{
var msg=document.getElementById("msg");
msg.innerHTML=xmlhttp.responseText;
return true;
}
}
xmlhttp.send("act="+encodeURIComponent(escape(post)));
}
setInterval("update()",2000)
</script>
<div
id="msg"></div>
后台update.asp
<%Response.CodePage=936%>
<%
Response.Charset="gb2312"
Response.Write Unescape(Request("act"))
%>