【1】http://www.ibm.com/developerworks/web/library/wa-ajaxintro2/index.html
1. web2.0? 什么是web1.0
具有完全不同的请求和响应模型的传统web
- web1.0 不支持异步请求
- web2.0 支持异步请求
2. XMLHttpRequest属性和方法
open()
: Sets up a new request to a server.send()
: Sends a request to a server.abort()
: Bails out of the current request.readyState
: Provides the current HTML ready state.responseText
: The text that the server sends back to respond to a request.
static javascript: 代码没有放在一个方法或者函数体内,在用户与页面交互之前运行
可以将创建XMLHttpRequest的代码放在函数里面,但是会有问题:如果你是在用户填入第14个文本框时执行Ajax代码,然后回复一个浏览器不支持的错误给用户,会导致一个非常差的体验,因为用户已经在这个页面花掉了10分钟的时间。所以还是建议使用static的代码。
ajax sandbox: 【2】http://www.cnblogs.com/ComeOn/archive/2008/01/30/1058942.html
AJAX中的沙箱安全模型主要指的是跨域脚本调用的问题。比如我们存在在中的脚本如果想访问 脚本是违反沙箱安全模型的。结果肯定会出错。
http ready state
- 0: The request is uninitialized (before you've called
open()
). - 1: The request is set up, but hasn't been sent (before you've called
send()
). - 2: The request was sent and is being processed (you can usually get content headers from the response at this point).
- 3: The request is being processed; often some partial data is available from the response, but the server hasn't finished with its response.
- 4: The response is complete; you can get the server's response and use it.