深入了解HTTP就绪状态。
首先,您需要学习在每种就绪状态下可能碰到的是哪种请求状态。
First and foremost, you need to learn at what state of a request you encounter each ready state.
另外,未初始化的就绪状态在实际的应用程序中是没有真正的用处的。
Furthermore, the uninitialized ready state is pretty useless in practical applications.
所有的文档和规范都强调,只有在就绪状态为4时数据才可以安全使用。
All of the documentation and specifications insist that it's only when the ready state is 4 that data is safe to use.
例如,在使用Opera 8.5时,所显示的就绪状态情况就更加糟糕了。
For example, when using Opera 8.5, things are even worse with displayed ready states.
比较好的做法是向用户提供一些反馈,说明在处于就绪状态3时,很快就会有响应了。
A better idea is to provide some feedback to the user that when the ready state is 3, a response is forthcoming.
您会看到就绪状态为3的响应在每个脚本、每个服务器甚至每个浏览器上都是不一样的。
You'll find that your responses in ready state 3 vary from script to script, server to server, and browser to browser.
而第四项也是最后一项必需的更改是使RMock模拟对象脱离记录状态转入就绪状态。
And the fourth and final change required is to bring the RMock mock object out of record state into ready state.
这个回调函数会运行多次——每次就绪状态都会改变——您可以看到每个就绪状态的警告。
Your callback function will run several times — each time the ready state of the request changes — and you'll see an alert for each ready state.
换句话说,服务器履行了请求(即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.
一个程序、任务或硬件设备在处于就绪状态时,只需要一个起动信号就开始工作。
A program, task, or hardware device that is in a ready condition needs only a start signal in order to begin operation.
与就绪状态类似,responsetext属性的值在整个请求的生命周期中也会发生变化。
Like the ready state, the value of the responseText property changes throughout the request's life cycle.
在Opera上,您永远都不会看到前两个就绪状态,而在Safari上则没有第一个(1)。
On Opera, you'll never get those first two ready states and Safari drops the first one (1).
要查看这种变化,请使用如 清单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.
如果就绪状态为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.
请求的就绪状态发生变化时,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
然而,由于服务器对请求进行了应答,因此就绪状态就被设置为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).
若要将测试套件的状态变更为可执行测试案例的就绪状态,请选取测试套件阶层窗格中的测试套件。
To change the state of a test suite to the ready state so that the test cases can be run, select the test suite in the test suite hierarchy pane.
如果您可以考虑各种就绪状态——并且理解了这些就绪状态在不同浏览器之间的区别——就可以快速调试应用程序了。
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.
其中的第一点,即就绪状态,将在下一篇文章中详细讨论,您将进一步了解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.
对于Ajax编程,需要直接处理的惟一状态就是就绪状态4,它表示服务器响应已经完成,可以安全地使用响应数据了。
For Ajax programming, the only state you need to deal with directly is ready state 4, indicating that a server's response is complete and it's safe to check the response data and use it.
清单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.
第一种就绪状态的特点是readyState属性为0(readyState == 0),表示未初始化状态。
The first ready state, signified by the readyState property 0 (readyState == 0), represents an uninitialized request.
在就绪状态发生变化后,将调用req . onreadystatechange属性中指定的函数(请参见清单17)。
After the ready state changes, the function specified in the req.onreadystatechange property is invoked (see Listing 17).
然而,如果您不仅仅是想了解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.
在很多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.
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.
当完成一个CR时,它就被置为发布就绪状态,这个状态一直保持到每两个星期中的第二个星期三。 此时正是计划的发布日期。
When a CR is complete it sits in the Release Ready state until a scheduled release happens on every second Wednesday.
不过为了满足我们的兴趣,请参见 清单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.
如果就绪状态是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).
应用推荐