本人最近正在学习asp.net技术,想利用XmlHttp做一个无刷新页面进行循环查询数据库的功能,源码见下面。但是出现一些奇怪问题,在NotesMonitor.aspx页面第一次load时,可以正常取回SearchNotes.aspx页面的返回值,但是继续循环使用XmlHttp时,就无法正常取得SearchNotes.aspx页面的返回值,XmlHttp.responseText所获得的值永远是第一次的值,这是为什么?不知道我说清楚没有,恳请各位高手指教。非常感谢!!NotesMonitor.aspx代码:private void Page_Load(object sender, System.EventArgs e)
{
      string strUrl = "../yptzd/SerchNotes.aspx?searchZt=dk";
      strScript = @"<script language=javascript>LoopSearch('"+strUrl+"')</script>";
      if(!Page.IsStartupScriptRegistered("strScript"))
     { 
Page.RegisterStartupScript("strScript",strScript); 
     }
}
NotesMonitor.aspx的Html代码:
function Search(sUrl)
{
this.strUrl = sUrl;
this.objXmlHttpRequest=null;
if (window.XMLHttpRequest)
{
this.objXmlHttpRequest = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
if(connect("Microsoft.XMLHTTP")
this.objXmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
}
Search.prototype.RunProcess = function()
{
this.objXmlHttpRequest.open("GET",this.strUrl,false);
try
{
this.objXmlHttpRequest.send();
}
catch(e)
{
alert("此时无法进行验证。");
}
this.FunctionProcess();
}
Search.prototype.FunctionProcess = function()
{
switch(this.objXmlHttpRequest.readyState)
{
case 4:
{
if (this.objXmlHttpRequest.status == 200)
{
if(this.objXmlHttpRequest.responseText.substring(0,6) == "Exists")
{
    var strZt = this.objXmlHttpRequest.responseText.substring(6,8);//此处只有第一次运行可以正常返回值,若重复调用该方法返回的都是第一次的值。
   
    WriteMq("../yptzd/yptzd_dk_bro.aspx?op=2&dqzt="+strZt,"您有未处理的通知单");
this.objXmlHttpRequest = null;
}
else
{
   this.objXmlHttpRequest = null;
   setTimeout("LoopSearch('"+this.strUrl+"')",5000);
}
}
break;
}
}
}
function WriteMq(strUrl,strMsg)
{
    略...
}
function LoopSearch(sUrl)
{
var objRet = new Search(sUrl);
objRet.RunProcess();
}SearchNotes.aspx代码(被XmlHttp调用的页面):public class SerchNotes : System.Web.UI.Page
{

private void Page_Load(object sender, System.EventArgs e)
{
strZt = this.Request["searchZt"].ToString();
if(strZt.Length == 0)
{
return;
}
strStatement = @"select top 1 tzdbh,dqzt from yptzd_title where dqzt = '"+strZt+"'";
DataBaseAcc dba = new DataBaseAcc();
DataSet ds = dba.GetDs(strStatement);
if(ds.Tables[0].Rows.Count >= 1)
{
strReInfo = "Exists";
strZt = ds.Tables[0].Rows[0]["dqzt"].ToString();
}
else
{
strReInfo = "NotExists";
}
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, Response.ContentEncoding);
writer.Formatting = System.Xml.Formatting.Indented;  
writer.Indentation = 4;  
writer.IndentChar = ' ';
writer.WriteString(strReInfo+strZt);
writer.Flush();  
Response.End();  
writer.Close();
}