1、客户端:
function callXMLHttp()
{
var strurl;
var result;
strurl = XMLHttpServer.aspx?strID=100;
var objHttp = new ActiveXObject(Microsoft.XMLHTTP);
objHttp.open(get, strurl, false);
objHttp.send();
result = objHttp.ResponseText;
}
2、服务器端:
private void Page_Load(object sender, System.EventArgs e)
{
if (Request.QueryString.Keys.Count > 0 && Request.QueryString[strID].Length > 0)
{
strID = Request.QueryString[strID].ToString();
}
Response.Write(要返回的值);
}
还有一种写法:
function Test(objSrc,objDes)
{
try {
xmlHttp = new ActiveXObject(Microsoft.XMLHTTP);
} catch(e) {
xmlHttp = new XMLHttpRequest();
}
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var data = xmlHttp.responseText;
document.getElementById(objDes).value = data;
}
}
}
xmlHttp.open(GET,CodeNameServer.aspx?testid= + objSrc.value);
xmlHttp.send(null);
}