XMLHttpRequest 对象
属性列表属性 | 描述 |
---|---|
onreadystatechange | Sets or retrieves the event handler for asynchronous requests. |
readyState | Retrieves the current state of the request operation.(查看) |
responseBody | Retrieves the response body as an array of unsigned bytes. |
responseText | Retrieves the response body as a string. |
responseXML | Retrieves the response body as an XML Document Object Model (DOM) object. |
status | Retrieves the HTTP status code of the request.(查看) |
statusText | Retrieves the friendly HTTP status of the request. |
方法列表
方法 | 描述 |
---|---|
abort | Cancels the current HTTP request. |
getAllResponseHeaders | Returns the complete list of response headers. |
getResponseHeader | Returns the specified response header. |
open | Assigns method, destination URL, and other optional attributes of a pending request. |
send | Sends an HTTP request to the server and receives a response. |
setRequestHeader | Adds custom HTTP headers to the request. |
请求操作的当前状态
(0)UNINITIALIZED | The object has been created, but not initialized (the open method has not been called). |
(1) LOADING | The object has been created, but the send method has not been called. |
(2) LOADED | The send method has been called, but the status and headers are not yet available. |
(3) INTERACTIVE | Some data has been received. Calling the responseBody and responseText properties at this state to obtain partial results will return an error, because status and response headers are not fully available. |
(4) COMPLETED | All the data has been received, and the complete data is available in the responseBody and responseText properties. |
HTTP请求的状态码
Number | Description |
---|---|
100 | Continue |
101 | Switching protocols |
200 | OK |
201 | Created |
202 | Accepted |
203 | Non-Authoritative Information |
204 | No Content |
205 | Reset Content |
206 | Partial Content |
300 | Multiple Choices |
301 | Moved Permanently |
302 | Found |
303 | See Other |
304 | Not Modified |
305 | Use Proxy |
307 | Temporary Redirect |
400 | Bad Request |
401 | Unauthorized |
402 | Payment Required |
403 | Forbidden |
404 | Not Found |
405 | Method Not Allowed |
406 | Not Acceptable |
407 | Proxy Authentication Required |
408 | Request Timeout |
409 | Conflict |
410 | Gone |
411 | Length Required |
412 | Precondition Failed |
413 | Request Entity Too Large |
414 | Request-URI Too Long |
415 | Unsupported Media Type |
416 | Requested Range Not Suitable |
417 | Expectation Failed |
500 | Internal Server Error |
501 | Not Implemented |
502 | Bad Gateway |
503 | Service Unavailable |
504 | Gateway Timeout |
505 | HTTP Version Not Supported |