/*--------前台JS代码-----------*/	
var http_request;
function GetAjaxObject(coaInfo)
{
     //根据浏览器的不同来获取XMLHttpRequest对象
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
                http_request = new XMLHttpRequest();
        }
        else if (window.ActiveXObject) { // IE
        	http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }
     //设置XMLHttpRequest对象的参数
        var linkUrl = "RetentionAC.aspx?val="+coaInfo;
        var queryString = "vasl="+coaInfo;
        http_request.open("POST",linkUrl,false);
        http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        http_request.onreadystatechange = function(){
        if(http_request.readyState == 4)
        {
        	if(http_request.status == 200)
                {
                	document.getElementById("ctl00_cphContent_hidCOAInfo").value = http_request.responseText;
                }
        }
};
http_request.send(queryString);//向服务器发送Ajax 请求。
/*----------------------------------------------*/
/*----------后台C#代码----------------*/
if (Request.QueryString["val"] != null)
{
	string strResult = BllCommonCostAllocation.CheckSingleCOAInfo(Request.QueryString["val"].ToString());
	Response.Write(strResult); //CallBack函数中的responseText的值
	Response.End();//必不可少,必须要结束,否则会返回整个HTML文件
}
/*-------------------------------------*/
.net使用Ajax在前台调用后台方法,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/jake-hl/p/3756990.html