引用地址:http://birdshover.cnblogs.com/archive/2006/07/03/441439.html
AJAX出来的时间也不短了。虽然它在某些方面很受争议,但是瑕不掩瑜。AJAX不能说它属于哪门语言,而是任何一门语言与JavaScript,XML的交叉。我觉得,说Ajax是任何一门WEB语言与DHTML、XML的交叉这样更加合适。
以下只讨论IE部分。
Ajax在应用中使用有3个部分(个人观点): 1、数据(一般通过IE内置组件Microsoft.XMLHTTP来取得或者发送数据); 2、事件(事件指的是客户端事件,如果是服务端事件,那么AJAX也就没什么意义了); 3、绑定(暂且就叫绑定吧,也可以说是显示,一般通过DHTML来完成)。
从上面看,Ajax就使用了Microsoft.XMLHTTP组件和DHTL。其实还有另外一部分,就是服务器端的处理。
一、简单示例 就最简单的原型来说,就是取得数据: a.aspx的内容如下:

b.aspx取得

















a.aspx提供可数据 xmlhttp.open("GET","a.aspx",true);就是请求a.aspx
if (xmlhttp.readyState==4) { MyShow.InnerText = xmlhttp.responseText;
} 当异步请求完成时,用DHML改变MyShow的内容。
二、GET方法 更改a.aspx如下:












把b.aspx中 xmlhttp.open("GET","a.aspx",true);改成xmlhttp.open("GET","a.aspx?flag=1",true); 则得到数据11111111111111 xmlhttp.open("GET","a.aspx",true);改成xmlhttp.open("GET","a.aspx?flag=2",true); 则得到数据22222222222222
三、POST方法 如果有这样一个表单 <form method=post> <input name="p1" type=text /> <input name="p2" type=submit/> </form> 用AJAX就是

















而一般模拟请求都是POST和Get同时存在的 只要把 xmlhttp.open("Post","a.aspx",true); 里a.aspx加上get请求部分就可以了。
而在.Net中特别得,可以把Ajax写成服务器组件来使用。现在在实际项目中如果使用Ajax很多的情况,就有个专门的组件来使用了。还有就是要注意,在很多时候Ajax的时候要设置页面不缓存。而如果要兼容非IE内核浏览器,那么就要注意各种内核浏览器的JS是否兼容了。