Your callback function will receive as parameters an event object representing the status of the remote call, and the result object returned by the remote Apex method. Your function can update information and user interface elements on the page based on the data returned.
Field | Description |
---|---|
event.status | true on success, false on error. |
event.type | The type of the response: rpc for a successful call, exception if the remote method threw an exception, and so on. |
event.message | Contains any error message that is returned. |
event.where | Contains the Apex stack trace, if one was generated by the remote method. |
Apex primitive data types returned by result—such as strings or numbers—are converted to their JavaScript equivalents. Apex objects that are returned are converted to JavaScript objects, while collections are converted to a JavaScript array. Keep in mind that JavaScript is case-sensitive, so id, Id, and ID are considered different fields.
As part of a JavaScript remote call, if the Apex method response contains references to the same object, the object won’t be duplicated in the returned JavaScript object, and instead, the rendered JavaScript object will contain references to the same object. An example is an Apex method which returns a list that contains the same object twice.