Thursday, 27 February 2014

Handling the Remote Response in JavaScript Remoting

The Callback Function receives 2 parameters

  • Event object: represents the status of the remote call

    •   event.status : true on success, false on error.
    •   event.type :  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.


  • Result object: represents result returned by the remote Apex 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,
    • Collections are converted to a JavaScript array.
    • Keep in mind that JavaScript is case-sensitive, so id, Id, and ID are considered different fields.

Points to remember

  •   The remote method call executes synchronously, but it doesn’t wait for the response to return.
  •   When the response returns, the callback function handles it asynchronously.
  •   By default, the response of the remote call must return within 30 seconds, after which the call will time out. If your request needs longer to complete, configure a longer timeout, up to 120 seconds.
  •   The response of the remote call has a maximum size of 15 MB.

1 comment:

  1. Hi,
    Using javascript remote controller How to display Dynamically(Every time comming) comming multiselectpicklist vales as Checkboxes in an visualforce page?

    ReplyDelete

Thank you for visiting. Your comments are highly appreciated.