AjaxResponse
class
stable
A normalized response from an AJAX request. To get the data from the response, you will want to read the response
property.
class AjaxResponse<T> { constructor(originalEvent: ProgressEvent<EventTarget>, xhr: XMLHttpRequest, request: AjaxRequest, type: any = 'download_load') get status: number get response: T get responseType: XMLHttpRequestResponseType get loaded: number get total: number get responseHeaders: Record<string, string> get originalEvent: ProgressEvent get xhr: XMLHttpRequest get request: AjaxRequest get type: AjaxResponseType }
Description
- DO NOT create instances of this class directly.
- DO NOT subclass this class.
It is advised not to hold this object in memory, as it has a reference to the original XHR used to make the request, as well as properties containing request and response data.
Constructor
A normalized response from an AJAX request. To get the data from the response, you will want to read the response
property.
constructor(originalEvent: ProgressEvent<EventTarget>, xhr: XMLHttpRequest, request: AjaxRequest, type: any = 'download_load')
Parameters
originalEvent | The original event object from the XHR |
xhr | The |
request | The request settings used to make the HTTP request. |
type | Optional. Default is The type of the event emitted by the |
- DO NOT create instances of this class directly.
- DO NOT subclass this class.
Properties
Property | Type | Description |
---|---|---|
status
| number |
Read-only. The HTTP status code |
response
| T |
Read-only. The response data, if any. Note that this will automatically be converted to the proper type |
responseType
| XMLHttpRequestResponseType |
Read-only. The responseType set on the request. (For example: |
loaded
| number |
Read-only. The total number of bytes loaded so far. To be used with |
total
| number |
Read-only. The total number of bytes to be loaded. To be used with |
responseHeaders
| Record<string, string> |
Read-only. A dictionary of the response headers. |
originalEvent
| ProgressEvent |
Read-only. The original event object from the raw XHR event. The original event object from the XHR |
xhr
| XMLHttpRequest |
Read-only. The XMLHttpRequest object used to make the request. NOTE: It is advised not to hold this in memory, as it will retain references to all of it's event handlers and many other things related to the request. The |
request
| AjaxRequest |
Read-only. The request parameters used to make the HTTP request. The request settings used to make the HTTP request. Declared in constructor. |
type
| AjaxResponseType |
Read-only. The event type. This can be used to discern between different events if you're using progress events with The event type consists of two parts: the
|
See Also
© 2015–2021 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/ajax/AjaxResponse