您的位置:首页 > 其它

Ajax技术简单入门

2005-10-01 11:28 525 查看
随着Google公司推出的Gmail服务后,越来越多的人开始关注Ajax技术了,所谓Ajax(Asynchronous JavaScript and XML缩写)技术,就是指运用JavaScript和XML在不用刷新Web页的情况下与Web服务器通信的技术.
一般来说,使用Ajax技术主要有两个原因:一是fast;二是cool。
下面通过一个示例来说明Ajax的使用:
1.HTML代码
btn1用来调用Ajax代码(请求服务器并将返回信息填充到select1里)。

1 <select id="select1">select>
2 <input id="btn1" value="Fill Select" type="button" onclick="getOptions();">
2.JavaScript代码调用Ajax

1// Create the Request object (the AJAX wrapper)
2var request = new Request();
3// Change this to fit your environment
4var url = "http://localhost/ajax/";
5function getOptions()
6protected string result = string.Empty;
2private void Page_Load(object sender, System.EventArgs e)
3{
4 for (int i=0; i<10; i++)
5 {
6 result += i.ToString() + "|option " + i.ToString() + "~";
7 }
8 result = result.Substring(0, result.Length - 1); // to drop the last '~'
9}
更多Ajax
下载:源文件 项目测试
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: