Ajaxjs.js页面
///调用方法,返回指定的内容
function Ajax(url){
var m_xmlReq=null;
if(window.ActiveXObject)
{
try
{
m_xmlReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e)
{
try{m_xmlReq = new ActiveXObject('Microsoft.XMLHTTP');}catch(e){}
}
}
else if(window.XMLHttpRequest)
{
m_xmlReq = new XMLHttpRequest();
}
this.post=function(d)
{
if(!m_xmlReq) return;
m_xmlReq.open('POST',url,false);
m_xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
m_xmlReq.send(d);
//return eval("("+m_xmlReq.responseText+")"); //成功
return m_xmlReq.responseText;
}
}
index.aspx页面
<script type="text/javascript">
function getAjax() {
var checker_ajax1 = new Ajax("Handler1.ashx");
var param = "resumeId=" + $("Text1").value;
var temp1 = checker_ajax1.post(param);
alert("temp1为返回来的值:"+temp1);
}
</script>
一般处理程序页面:Handler1.ashx
返回得到的值 context.Response.Write(context.Request["resumeId"]);