You need to sign in to do that
Don't have an account?
Adam Bengtson
Allow visualforce remoting on a basic html page
I have an issue where I created a visualforce page that uses js visualforce remoting. I have to move this page into a communities subpage which does not allow you to host it as it is, instead you have to drop it in as html but in the process you cannot carry over the apex tags:
<apex:page controller="ApexController" sidebar="false" showHeader="false" applyBodyTag="false" applyHtmlTag="false">Now I no longer have the connection to my controller. Is there a way I can connect this back in a different way so I can use the visualforce remoting api?
JavaScript remoting in Visualforce provides support for some methods in Apex controllers to be called via JavaScript.
JavaScript remoting has three parts:
- The remote method invocation you add to the Visualforce page, written in JavaScript.
- The remote method definition in your Apex controller class. This method definition is written in Apex, but there are few differences from normal action methods.
- The response handler callback function you add to or include in your Visualforce page, written in JavaScript.
To use JavaScript remoting in a Visualforce page, add the request as a JavaScript invocation with the following form:[namespace.]controller.method( [parameters...,] callbackFunction, [configuration] );
- Namespace is the namespace of the controller class. This is required if your organization has a namespace defined, or if the class comes from an installed package.
- Controller is the name of your Apex controller.
- Method is the name of the Apex method you’re calling.
- Parameters is the comma-separated list of parameters that your method takes.
- CallbackFunction is the name of the JavaScript function that will handle the response from the controller. You can also declare an anonymous function inline. callbackFunction receives the status of the method call and the result as parameters.
- Configuration configures the handling of the remote call and response. Use this to specify whether or not to escape the Apex method’s response. The default value is {escape: true}.
Please find the below sample example on a normal visualforce page:Visuaforce Page:
Apex Controller:
Output:
For visualforce remoting on a html page please refer to the below link
https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/vf_dev_best_practices_approaches_remoting.htm
Please mark this post as solved if this helps.
Best Regards,
Nagendra.P