您会看到就绪状态为3的响应在每个脚本、每个服务器甚至每个浏览器上都是不一样的。
You'll find that your responses in ready state 3 vary from script to script, server to server, and browser to browser.
要查看这种变化,请使用如 清单5所示的代码来测试请求的响应文本,以及它们的就绪状态。
To see this in action, use code like that shown in Listing 5 to test the response text of a request, as well as its ready state.
可以执行跳转的源活动的可能状态包括:已请求、就绪、正在运行、已停止和正在等待。
The possible states of the source activity to perform a jump are: claimed, ready, running, stopped, and waiting.
换句话说,服务器履行了请求(即HTTP就绪状态是4)但是没有返回客户机预期的数据。
In other words, the server fulfilled the request (meaning the HTTP ready state is 4), but is probably not returning the data expected by the client.
如果您得到一个声明SOL尚未就绪的错误消息,请检查SOL的状态。
If you receive an error message saying that SOL is not ready, please check the SOL state.
所有的文档和规范都强调,只有在就绪状态为4时数据才可以安全使用。
All of the documentation and specifications insist that it's only when the ready state is 4 that data is safe to use.
其中的第一点,即就绪状态,将在下一篇文章中详细讨论,您将进一步了解HTTP请求的阶段,可能比您设想的还多。
The first of these — ready states — is going to take up the bulk of the next article; you'll learn more about the stages of an HTTP request than you ever wanted to know.
另外,未初始化的就绪状态在实际的应用程序中是没有真正的用处的。
Furthermore, the uninitialized ready state is pretty useless in practical applications.
然而,由于服务器对请求进行了应答,因此就绪状态就被设置为4(即使应答并不是请求所期望的也是如此)。
However, the ready state will be set to 4 since the server answered the request (even if the answer wasn't what you wanted or expected for your request).
要更好地看到这段代码的效果,请使用Firefox或InternetExplorer,因为这两个浏览器都可以报告出请求过程中所有可能的就绪状态。
To get the most out of this code, use either Firefox or Internet Explorer since those two browsers both report all possible ready states during a request.
一旦我们理解在请求过程中发生的各个就绪状态之后,接下来就可以来看一下XMLHttpRequest对象的另外一个方面了——responsetext属性。
Once you understand the various ready states that occur during a request, you're ready to look at another important piece of the XMLHttpRequest object — the responseText property.
在很多Ajax应用程序中,您将看到一个回调函数,它负责检查就绪状态,然后继续利用从服务器响应中返回的数据,如清单6所示。
In many Ajax applications, you'll see a callback function that checks for a ready state and then goes on to work with the data from the server response, as in Listing 6.
在Opera上,您永远都不会看到前两个就绪状态,而在Safari上则没有第一个(1)。
On Opera, you'll never get those first two ready states and Safari drops the first one (1).
与就绪状态类似,responsetext属性的值在整个请求的生命周期中也会发生变化。
Like the ready state, the value of the responseText property changes throughout the request's life cycle.
不过为了满足我们的兴趣,请参见 清单2 的内容,其中显示了如何在 readyState被设置为 0 时来获取这种就绪状态。
Still, in the interest of being complete, check out Listing 2 which shows how to get the ready state when it's set to 0.
例如,在使用Opera 8.5时,所显示的就绪状态情况就更加糟糕了。
For example, when using Opera 8.5, things are even worse with displayed ready states.
在大部分Ajax编程的真实情况中,这种就绪状态的唯一用法就是使用相同的XMLHttpRequest对象在多个函数之间生成多个请求。
The only use for this ready state in almost-real-world Ajax programming is if you make multiple requests using the same XMLHttpRequest object across multiple functions.
深入了解HTTP就绪状态。
Safari实际上把第一个就绪状态给丢弃了,也并没有什么明显的原因说明为什么要这样做;不过这就是Safari的工作方式。
Safari actually leaves out the first ready state and there's no sensible explanation as to why; it's simply the way Safari works.
然而,如果您不仅仅是想了解Ajax编程的常识,而是希望了解更多内容,就需要熟悉就绪状态、状态代码和请求本身的内容。
However, you will need to be fluent in ready states, status codes, and requests if you want to do more than just dabble in Ajax programming.
清单1相当简单;清单4稍微有点复杂,但是它们在开始时都要检查就绪状态,并获取responsetext属性的值。
Listing 1 is fairly simple; Listing 4 is a little more complicated, but to begin, both check the ready state and then grab the value (or values) in the responseText property.
在就绪状态发生变化后,将调用req . onreadystatechange属性中指定的函数(请参见清单17)。
After the ready state changes, the function specified in the req.onreadystatechange property is invoked (see Listing 17).
请求的就绪状态发生变化时,req.onreadystatechange中指定的函数将被调用。
When the ready state of a request changes, the function specified in req.onreadystatechange is invoked. req.readystate contains one of the following status codes
在数据结构、状态变量和函数定义就绪后,请在第3163行中添加load_shadow_dynamics函数。
After the data structures, state variables, and function definitions are in place, add the load_shadow_dynamics function at line 3163.
如果您可以考虑各种就绪状态——并且理解了这些就绪状态在不同浏览器之间的区别——就可以快速调试应用程序了。
If you can account for the various ready states — and understand how they differ from browser to browser — you'll be able to debug an application quickly.
当人工任务被调用时,它要么处于就绪(还未认领)状态,要么处于已认领状态。
When a human task is invoked, it is either in the ready (not yet claimed) or the claimed state.
比较好的做法是向用户提供一些反馈,说明在处于就绪状态3时,很快就会有响应了。
A better idea is to provide some feedback to the user that when the ready state is 3, a response is forthcoming.
使用该软件,您就可以创建一个可定制的操作板,以快速和轻松查看系统质量工具以及项目状态,例如测试已经就绪的构建。
Using this software, you can create a customizable dashboard for quick and easy review of systems quality metrics and project status, such as builds ready to be tested.
如果就绪状态为4,我们不仅要运行回调函数中的代码,而且还要在每次调用回调函数时都输出就绪状态。
Instead of only running code in your callback if the ready state is 4, just output the ready state every time that your callback is called.
如果就绪状态是4而且状态码是 200,就可以处理服务器的数据了,而且这些数据应该就是要求的数据(而不是错误或者其他有问题的信息)。
With a ready state of 4 and a status code of 200, you're ready to process the server's data and that data should be what you asked for (and not an error or other problematic piece of information).
应用推荐