class Ajax.Response

Description

A wrapper class around XmlHttpRequest for dealing with HTTP responses of Ajax requests.

An instance of Ajax.Response is passed as the first argument of all Ajax requests' callbacks. You will not need to create instances of Ajax.Response yourself.

Class methods

  • getAllResponseHeaders #

    Ajax.Response.getAllResponseHeaders() ⇒ String

    Returns a string containing all headers separated by line breaks; throws an error if no headers exist. This is just a wrapper around the XmlHttpRequest method of the same name.

  • getResponseHeader #

    Ajax.Response.getResponseHeader(name) ⇒ String

    Returns the value of the requested header if present; throws an error otherwise. This is just a wrapper around the XmlHttpRequest method of the same name.

Instance methods

  • getAllHeaders #

    Ajax.Response#getAllHeaders() ⇒ String | null

    Returns a string containing all headers separated by line breaks. _Does not__ throw errors if no headers are present the way its native counterpart does.

  • getHeader #

    Ajax.Response#getHeader(name) ⇒ String | null

    See Ajax.Request#getHeader.

Instance properties

  • headerJSON #

    Ajax.Response#headerJSON -> Object | Array | null

    Auto-evaluated content of the X-JSON header if present; null otherwise.

  • readyState #

    Ajax.Response#readyState -> Number

    The request's current state.

    0 corresponds to "Uninitialized", 1 to "Loading", 2 to "Loaded", 3 to "Interactive", and 4 to "Complete".

  • request #

    Ajax.Response#request -> Ajax.Request | Ajax.Updater

    The request object itself (an instance of Ajax.Request or Ajax.Updater).

  • responseJSON #

    Ajax.Response#responseJSON -> Object | Array | null

    The JSON body of the response if the Content-type of the request is set to application/json; null otherwise.

  • responseText #

    Ajax.Response#responseText -> String

    The text body of the response.

  • responseXML #

    Ajax.Response#responseXML -> document | null

    The XML body of the response if the Content-type of the request is set to application/xml; null otherwise.

  • status #

    Ajax.Response#status -> Number

    The HTTP status code sent by the server.

  • statusText #

    Ajax.Response#statusText -> String

    The HTTP status text sent by the server.

  • transport #

    Ajax.Response#transport -> XmlHttpRequest

    The native XmlHttpRequest object itself.