Class: SC.Response
A response represents a single response from a server request and handles the communication to
the server. An instance of this class is returned whenever you call SC.Request.send()
.
SproutCore only defines one concrete subclass of SC.Response
,SC.XHRResponse
. In order to
use SC.Request
with a non-XHR request type you should create a custom class that extends
SC.Response
and set your custom class as the value of responseClass
on all requests.
For example,
var request = SC.Request.getUrl(resourceAddress)
.set('responseClass', MyApp.CustomProtocolResponse)
.send();
To extend SC.Response
, please look at the property and methods listed below. For more examples,
please look at the code in SC.XHRResponse
.
Defined in: response.js
- Since:
- SproutCore 1.0
Field Summary
Instance Methods
- cancel()
- cancelTransport()
- fire()
- invokeTransport()
- notify()
- receive(callback, context)
- timeoutReached()
- toString()
Field Detail
address StringThe response body or the parsed JSON. Returns a SC.Error
instance
if there is a JSON parsing error. If isJSON
was set, will be parsed
automatically.
- Default value:
- null
- Default value:
- `this`
- Default value:
- null
- Default value:
- NO
- Default value:
- NO
If set then will attempt to automatically parse response as JSON regardless of headers.
- Default value:
- NO
If set, then will attempt to automatically parse response as XML regardless of headers.
- Default value:
- NO
The request object that originated this request series. Mostly this is useful if you are looking for a reference to the original request. To inspect actual properties you should use request instead.
Request used to generate this response. This is a copy of the original request object as you may have modified the original request object since then.
To retrieve the original request object use originalRequest
.
- Default value:
- null
- Default value:
- -100
Set to YES
if the request timed out. Set to NO if the request has
completed before the timeout value. Set to null if the timeout timer is
still ticking.
- Default value:
- null
- Default value:
- null
Instance Method Detail
Default method just closes the connection. It will also mark the request as cancelled, which will not call any listeners.
Called by the request manager when its time to actually run. This will invoke any callbacks on the source request then invoke transport() to begin the actual request.
Called by SC.Response#fire()
. Starts the transport by invoking the
SC.Response#receive()
function.
- Returns:
- SC.Response
- receiver
Invoked by the transport when it receives a response. The passed-in
callback will be invoked to actually process the response. If cancelled
we will pass NO
. You should clean up instead.
Invokes callbacks on the source request also.
- Parameters:
- callback Function
- the function to receive
- context Object
- context to execute the callback in
- Returns:
- SC.Response
- receiver
- Returns:
- Boolean
- YES if this response has not timed out yet, NO otherwise
- Returns:
- String