其实基本使用都明白,就是没有想到,举一个例子吧。
<script ype="text/javascript">
var xmlHttp;
//创建一个XmlHttpRequeset对象

function createXMLHttpRequest()...{

if(window.ActiveXObject)...{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}

else if(window.XMLHttpRequest)...{
xmlHttp = new XMLHttpRequest();
}
}
//开始一个请求

function startRequest()...{
createXMLHttpRequest();
xmlHttp.onreadystatechange = handlestatechange;
xmlHttp.open("GET", "innerHtml.xml", true);
xmlHttp.Send(null);
}

function handlestatechange()...{

if(xmlHttp.readyState == 4)...{//描述一种"已加载"状态;此时,响应已经被完全接收。

if(xmlHttp.status == 200)...{//200表示成功收到
document.getElementById("results").innerHTML = xmlHttp.ResponseText;
}
}
}
</script>
把innerHtml.xml换成aaa.aspx,然后把aaa.aspx里的html全部清空。只在aaa.aspx.cs的Page_Load函数里面写上想要的数据,然后就可以了。如下
protected void Page_Load(object sender, EventArgs e)

...{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();

string custID = Request.QueryString["CustID"].ToString().Trim();
//string custID = "11532";
string assetIDs = GetAssetIDsByCustID(custID);
Response.Write(assetIDs);

Response.End();
}


































把innerHtml.xml换成aaa.aspx,然后把aaa.aspx里的html全部清空。只在aaa.aspx.cs的Page_Load函数里面写上想要的数据,然后就可以了。如下
















这里的assetIDs可以做成字符串、xml、json。这里推荐json,因为这样传输比较好,据说.net现在也提供对json很好的支持。