readyState的五種狀態[轉載]

readyState的五種狀態[轉載]
2008-05-11 16:14
readyState的五種狀態[轉載]
2007-11-20 17:24
對於readyState的五種狀態的描述或者說定義,很多Ajax書(英文原版)中大都語焉不詳
在《Pragmatic Ajax A Web 2.0 Primer 》中偶然看到對readyStae狀態的介紹,感覺這個介紹很實在……
比較理想的解釋方法應該以“狀態:任務(目標)+過程+表現(或特徵)”的表達模式來對這幾個狀態進行定義

【全文】

在《Pragmatic Ajax A Web 2.0 Primer 》中偶然看到對readyStae狀態的介紹,感覺這個介紹很實在,摘譯如下:

0: (Uninitialized) the send( ) method has not yet been invoked. 
1: (Loading) the send( ) method has been invoked, request in progress. 
2: (Loaded) the send( ) method has completed, entire response received. 
3: (Interactive) the response is being parsed. 
4: (Completed) the response has been parsed, is ready for harvesting. 

0 - (未初始化)還沒有調用send()方法
1 - (載入)已調用send()方法,正在發送請求
2 - (載入完成)send()方法執行完成,已經接收到全部響應內容
3 - (交互)正在解析響應內容
4 - (完成)響應內容解析完成,可以在客戶端調用了


對 於readyState的這五種狀態,其他書中大都語焉不詳。像《Foundations of Ajax》中,只在書中的表2-2簡單地列舉了狀態的“名稱”--The state of the request. The five possible values are 0 = uninitialized, 1 = loading, 2 = loaded, 3 = interactive, and 4 = complete。而《Ajax in Action》中好像根本就沒有提到這5種狀態的細節。《Professional Ajax》中雖不盡人意,但還是有可取之處:

There are five possible values for readyState: 
0 (Uninitialized): The object has been created but the open() method hasn't been called. 
1 (Loading): The open() method has been called but the request hasn't been sent. 
2 (Loaded): The request has been sent. 
3 (Interactive). A partial response has been received. 
4 (Complete): All data has been received and the connection has been closed. 

readyState有五種可能的值:
0 (未初始化): (XMLHttpRequest)對象已經創建,但還沒有調用open()方法。
1 (載入):已經調用open() 方法,但尚未發送請求。
2 (載入完成): 請求已經發送完成。
3 (交互):可以接收到部分響應數據。
4 (完成):已經接收到了全部數據,並且連接已經關閉
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章