Difference between revisions of "Opensocial.DataResponse (v0.9)"
From VZ Developer Wiki
(Created page with '{{NeedsExamples}} <div style="float:right; margin: 0 0 10px 10px;">__TOC__</div> <span style="font-size:150%"><strong>opensocial.DataResponse</strong></span> This object contai…') |
(→Methods) |
||
Line 36: | Line 36: | ||
<div style="margin-left:4em;">Returns true if there was an error in fetching this data from the server.</div> | <div style="margin-left:4em;">Returns true if there was an error in fetching this data from the server.</div> | ||
+ | == Examples == | ||
+ | <source lang="javascript"> | ||
+ | function response(data) { | ||
+ | if (data.hadError()) { | ||
+ | output("Error: " + data.get("req").getErrorMessage()); | ||
+ | } else { | ||
+ | output(data.get("req").getData().getDisplayName()); | ||
+ | } | ||
+ | gadgets.window.adjustHeight(); | ||
+ | }; | ||
+ | |||
+ | function request() { | ||
+ | var req = opensocial.newDataRequest(); | ||
+ | req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER), "req"); | ||
+ | req.send(response); | ||
+ | }; | ||
+ | </source> | ||
{{ JsApiAlphaList_(v0.9) }} | {{ JsApiAlphaList_(v0.9) }} |
Latest revision as of 14:34, 11 November 2010
This documentation is not completed yet and will be extended by more examples in future.
opensocial.DataResponse
This object contains the requested server data mapped to the requested keys. See also: DataRequest
Methods
opensocial.DataResponse.get
opensocial.ResponseItem get(key)
- Parameters
Name Type Description key <c/> <c/>
- Returns
Type Description opensocial.ResponseItem The requested response calculated by the server
- Description
Gets the ResponseItem for the requested field.
opensocial.DataResponse.getErrorMessage
String getErrorMessage()
- Returns
Type Description String A human-readable description of the error that occurred.
- Description
If the entire request had a batch level error, returns the error message.
opensocial.DataResponse.hadError
Boolean hadError()
- Returns
Type Description Boolean True if there was an error; otherwise, false
- Description
Returns true if there was an error in fetching this data from the server.
Examples
function response(data) {
if (data.hadError()) {
output("Error: " + data.get("req").getErrorMessage());
} else {
output(data.get("req").getData().getDisplayName());
}
gadgets.window.adjustHeight();
};
function request() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER), "req");
req.send(response);
};
OpenSocial (v0.9) | |||
opensocial.DataResponse |