Activity › Forums › Salesforce® Discussions › What is AJAX typically used for in Salesforce Visualforce pages?
-
What is AJAX typically used for in Salesforce Visualforce pages?
Posted by suniti on June 28, 2018 at 10:45 AMWhat is AJAX typically used for in Salesforce Visualforce Pages?
shariq replied 7 years, 8 months ago 4 Members · 3 Replies -
3 Replies
-
Hi Suniti,
Visualforce has inbuilt support for the AJAX. using the attribute “rerender” we can specify that where the response should be rendered.
Lets have an example to demonstrate that how simple AJAX works in visualforce.
public class AjaxDemo {
private String currTime;
public String getCurrTime()
{
return currTime;
}
public void setCurrTime()
{
currTime = System.now().format(‘EEEE, MMMM d, yyyy – hh:mm:ss’);
}
}On the basis of above Apex class lets create Visualforce page with below code.
<apex:page Controller=”AjaxDemo”>
<apex:pageBlock Title=”Ajax Sample”>
Hello <b> {!$User.FirstName}</b>.
<apex:form >
<br /><br />
<apex:commandbutton action=”{!setCurrTime}” rerender=”ajaxresult” value=”Display Current Time” /></apex:form>
</apex:pageBlock><apex:pageBlock title=”AjaxData”>
<apex:outputPanel id=”ajaxresult” layout=”block”>
Result: {!CurrTime}
</apex:outputPanel>
</apex:pageBlock></apex:page>
- [adinserter block='9']
-
Hello Suniti,
AJAX Components are used to dynamically replace the content of a panel tag within a page without replacing the page in the browser window. These tags allow a more seamless, flicker-free user interface. User interactions with a page no longer need to submit/request entire pages, instead, pieces of the page can change as data is entered.
There are few AJAX components in Salesforce, which supports AJAX functionality. They are:- Action Function
- Action Poller
- Action Region
- Action Status
- Action Support
Hope this helps.!
-
Hi,
AJAX is primarily used for partial page updates in Visualforce. In s-controls, the AJAX toolkit was the soap (XML over HTTP) client that gave you access to the force.com Web Services API.
Hope this helps.
Log In to reply.