Saturday, December 10, 2016

Visualforce - Beyond Basics Series 10 - 5 ways to AJAX Calls

What is Ajax Call ?

After the initial page load, the client(browser) can interact with server asynchronously without page reload/redirection. This method is called AJAX technique. Its quite popular in modern web practices.

Why is it necessary ?

To build single page applications(SPA), we need to handle the interaction with server( POST calls) asynchronously & optionally update the portion of screen without full page reload. In order to achieve that AJAX calls are required.

What are the ways to achieve it ?

There are 5 ways one can use Ajax call in Visualforce,

  1. Remote Objects
  2. Action Functions
  3. Remote Methods
  4. SOAP API
  5. REST API


Where is code for each one ?

I have given example for each type, achieving the same result, i.e all the examples fetches 10 Opportunity records & display them in a div tag asynchronously.


Remote Objects


Action Functions


Remote Methods


SOAP API


REST API


A Class used for these examples,



No comments:

Post a Comment

Thanks for reading my blog !