我爱Aspx >> C#.Net >> 用.net 处理xmlHttp发送异步请求_ASP.NET技巧var clickRouter=new jsEvent.EventRouter(iobj,"onclick");
clickRouter.addListener(btnTestGetClick);
}
function btnTestGetClick()
{ // open参数 url, onload, params, method, contentType, onerror
cobj = new net.xmlHttp("DefaultHandler.ashx?T=1",dealResult, null, "GET");
}
/**//* Get end*/
function dealResult()
{
var dobj = document.getElementById("divResult");
dobj.innerHTML = cobj.req.responseXML.text;
}
window.onload = function()
{
//绑定Post发送xmlHttp事件到btnTestPost
loadTestPost();
//绑定Get发送xmlHttp事件到btnTestGet
loadTestGet();
};
最后是.net处理xmlHttp的代码
.net 处理xmlHttp请求
public class DefaultHandler : IHttpHandler
{
protected XmlDocument _xmlResult;
public void ProcessRequest(HttpContext context)
{
if (context.Request["T"] != null)
{//GET xmlhttp测试
context.Response.ContentType = "text/xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(string.Format(@"<time>GET:{0}</time>", System.DateTime.Now));
xmlDoc.Save(context.Response.OutputStream);
context.Response.End();
}
else
{//POST xmlhttp测试
context.Response.ContentType = "text/xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(context.Request.InputStream);
if (xmlDoc.DocumentElement.Name == "T")
{
xmlDoc.LoadXml(string.Format(@"<time>POST:{0}</time>", System.DateTime.Now));
xmlDoc.Save(context.Response.OutputStream);
context.Response.End();
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
http://www.cnblogs.com/Files/laiwen/XmlHttpNet.rar
http://www.cnblogs.com/laiwen/archive/2006/12/26/604050.html
Ҷƪл˵?
Ajax核心:XMLHTTP组件相关技术资..[04-28]
XMLHTTP对象封装技术_Ajax[04-28]
优化MICROSOFT ACCESS提高速度_A..[04-28]
最优化ASP程序性能_ASP技巧[04-28]
ASP中优化数据库处理_ASP技巧[04-28]
在ASP中优化数据库处理_ASP技巧[04-28]
最大限度优化你的Asp性能_ASP技巧[04-28]
用ASP编写计数器的优化方法_ASP技..[04-28]
ASPX页Web服务调用性能优化_ASP...[04-28]
微软建议的ASP性能优化28条守则_..[04-28]
Ajax核心:XMLHTTP组件相关技术资..[04-28]
XMLHTTP对象封装技术_Ajax[04-28]
优化MICROSOFT ACCESS提高速度_A..[04-28]
最优化ASP程序性能_ASP技巧[04-28]
MySQL优化全攻略-相关数据库命令..[04-28]
MySQL优化全攻略-服务器参数调整..[04-28]
MySQL怎样优化WHERE子句_数据库技..[04-28]
怎样获得SQL Server的优化性能?..[04-28]
ASP中优化数据库处理_ASP技巧[04-28]
在ASP中优化数据库处理_ASP技巧[04-28]