Salesforce RemoteAction and webService

In Salesforce,we can make asynchronous requests from Visualforce Page,via RemoteAction or webService.

I will share you the usage of RemoteAction and webService In this post.


Using RemoteAction(JavaScript Remoting) allows us to call methods in Apex controllers and get a callback with return data from JavaScript.
The @RemoteAction methods in Apex must be static and either global or public.
The following is the sample code for RemoteAction.




Using webService(Apex in AJAX) need to include the following lines in your AJAX code The webService methods in Apex must be static and Class must be global. Here is the sample code for webService.



The Difference

1. Using webService, can call not only the Page Controllers but also other Classes, which can be Common Classes.
2. Using webService, will cost API request,and RemoteAction will not.
3. Using webService, the methods of Class must be global.

Related Post

Batch Apex running mode (parallel and series) and ... In my early post, I’d shared about how to write a Schedulable Batch Apex in Salesforce, and I’ll show you how transactions run in batch Apex and how to maintain their state across these transactions in this post. Batch Apex running mode (parallel / series) As we know, each execution of a batch...
Using Custom Metadata Types and Custom Settings in... Custom Metadata is one of the new features that released at Summer'15 of Salesforce, which is customizable, deployable, packageable, and upgradeable application metadata, and it supports the following custom field types.   • Checkbox   • Date   • Date and Time  ...
Salesforce Mass Editor (Chrome Extension) – ... This's my second Chrome Extension (First one is HERE) this year, named "Salesforce Mass Editor" and it supports for doing the below things : ・Makes any Salesforce list view to be a powerful mass editor. ・Mass insert, mass clone, mass update, mass delete, ALL-IN-ONE. ・Export record data to CSV fi...
Setup an awesome Salesforce developer environment ... Why Sublime Text 3 ? I've been working with for about 2 years, and always using IDE(See here, Eclipse IDE Installation)as my development environment. I don't think it is difficult to use, but it could more friendly. For example: 1. It doesn't support APEX an...