Handling the Remote Response

Handle the response to a remote method call asynchronously in the remote method callback function.
Your callback function receives the following parameters:
  • event object representing the status of the remote call
  • 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.
The event object provides values that let you act upon the success or failure of the remote call.
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.
event.message Contains any error message that is returned.
event.where The Apex stack trace is referenced, if it is 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 is not duplicated in the returned JavaScript object. Instead, the rendered JavaScript object contains a reference to the same object. An example is an Apex method which returns a list that contains the same object twice.