I have a Remote action call from my Visualforce Page.
Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.PartnerPrimeSubController.calculatePartnerPrimeSub}', handlePartnerPrimeSubResult, {escape: false} );
and my controller “PartnerPrimeSubController” looks like this
@RemoteAction global static List<String> calculatePartnerPrimeSub(){ //Custom Code return finalJSONData; }
Is it possible to make JSRemoting Asynchronous?
I tried something like this and failed:
@future @RemoteAction global static List<String> calculatePartnerPrimeSub(){ //Custom code }
Use Case behind this requirement:
- I am trying to invoke 10 VF Remoting calls after DOM Load Complete in my Visualforce Page.
When i checked the network in chrome console, Salesforce tries to
process 1 VF remoting call at a time.- Salesforce completes 1 remoting call and 9 other VF Remoting call seems to be waiting until first remoting completes.
- I am also trying to improve the performance of my page by moving
away from Action Function and implementing Lazy loading through
VF Remoting.Any pointers?
Answer
I guess the answer is the SF document itself. Have a look at this link http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm
You can configure your remoting call using these three parameters “buffer“,”timeout” and “escape”. Usually written at the end of a call.
You have to look for the parameter “buffer“. As per the docs buffer decides
Whether to group requests executed close to each other in time into a
single request. The default is true.
So to make your individual call to the controller you have to set this parameter as
“false“
Example
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.MyController.getAccount}',
accountName,
function(result, event){
},
{ buffer: false, escape: true, timeout: 30000 }
);
Attribution
Source : Link , Question Author : Jag , Answer Author : Avidev9