用ajax读取Application里的数据问题 诚心求解
三个页面,前台为webform1,两个后台处理页面,分别为server.aspx和server1.aspx
由webform1分别向这两个页面提交请求,server.aspx采用,for(i=0;i <10;i++){Application[ "test "] = i;System.Threading.Thread.Sleep(5000);}提交数据到application,再用server1.aspx的
int i = (int)Application[ "test "];
//Application.UnLock();
//Response.Clear();
Response.ContentType = "text/xml ";
Response.Write(i.ToString());
Response.End();
返回数据给webform1,在用DOM创建接收到的数据为一个新行,我的原意是能够在webform1上面一行一行的显示,但是结果是只能在server.aspx执行完之后server1.aspx才能返回。各位有什么解决办法?
代码如下
webform1.aspx
<%@ Page language= "c# " Codebehind= "WebForm1.aspx.cs " AutoEventWireup= "false " Inherits= "test.WebForm1 " %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN " >
<HTML>
<HEAD>
<title> WebForm1 </title>
<script language= "javascript ">
var XmlReq1,XmlReq2;
var responseurl1 = "server.aspx ",responseurl2 = "server2.aspx ";
function CreateXmlReq1()
{
try
{
XmlReq1 = new ActiveXObject( "Msxml2.XMLHTTP ");
}
catch(e)
{
try
{
XmlReq1 = new ActiveXObject( "Microsoft.XMLHTTP ");
}
catch(oc)
{
XmlReq1 = null;
}
}
if(!XmlReq1 && typeof XMLHttpRequest != "undefined ")
{
XmlReq1 = new XMLHttpRequest();
}
}
function CreateXmlReq2()
{
try
{
XmlReq2 = new ActiveXObject( "Msxml2.XMLHTTP ");
}
catch(e)
{
try
{
XmlReq2 = new ActiveXObject( "Microsoft.XMLHTTP ");
}
catch(oc)
{
XmlReq2 = null;
}
}
if(!XmlReq2 && typeof XMLHttpRequest != "undefined ")
{
XmlReq2 = new XMLHttpRequest();
}
}
function onloada()
{
//alert( "onloada ");
document.Form1.txt1.value = "wwww ";
CreateXmlReq1();
if(XmlReq1)
{
XmlReq1.onreadystatechange = Res1;
XmlReq1.open( "get ",responseurl1,true);
XmlReq1.send();
}
window.setInterval(test2,2000);
}
function Res1()
{
if( XmlReq1.readyState == 4)
{
if( XmlReq1.status == 200)
{
}
}
}
function test2()
{
CreateXmlReq2();
XmlReq2.onreadystatechange = Res2;
XmlReq2.open( "get ",responseurl2,true);
XmlReq2.send();
}
function Res2()
{
if( XmlReq2.readyState == 4)
{
if( XmlReq2.status == 200)
{
document.Form1.txt1.value += XmlReq2.responseText;