I'm trying call this:
<apex:actionFunction name="doCallout" action="{!callout}" />
From javascript like this:
<script>
window.onload=function()
{
doCallout();
}
</script>
It works, but it seems to be stuck in either an infinite loop OR its constantly rerendering the page every half second. Adding "rerender" to the actionFunction doesn't seem to have any effect no matter what value I use.
Currently I'm using a command button to call the function(which is a callout to an outside webservice using REST) like this:
<apex:commandButton value="Callout" action="{!callout}" rendered="{!$CurrentPage.parameters.offline!='1'}"/>
The commandButton works fine and doesn't get the page to refresh every half second, but I need this callout to happen upon the page loading for seemless RESTful API callout experience.
Any thoughts?
EDIT: Pasting Full page code:
<apex:page id="page" controller="RSAPI_Controller" >
<apex:form id="form" >
<apex:actionFunction name="doCallout" action="{!callout}" />
<apex:sectionHeader title="RESTFUL Callout Viewer" />
<apex:pageMessages id="pageMessages" />
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Callout" action="{!callout}" rendered="{!$CurrentPage.parameters.offline!='1'}"/>
<apex:commandButton value="Deserialize" action="{!deserializeQuestions}" rendered="{!$CurrentPage.parameters.offline!='1'}"/>
<apex:commandButton value="Callout (offline)" action="{!callout}" rendered="{!$CurrentPage.parameters.offline=='1'}" />
<apex:commandButton value="Deserialize (offline)" action="{!deserializeQuestions}" rendered="{!$CurrentPage.parameters.offline=='1'}" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1" title="HttpRequest" collapsible="false" >
<apex:pageBlockSectionItem >
<apex:outputLabel value="setMethod()" />
<apex:selectList size="1" value="{!requestMethod}" >
<apex:selectOptions value="{!MethodOptions}" />
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="setEndpoint()" />
<apex:inputText value="{!requestEndpoint}" style="width:90%" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" title="HttpResponse" collapsible="false" >
<apex:pageBlockSectionItem >
<apex:outputLabel value="getStatusCode()" />
<apex:outputText value="{!responseStatusCode}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="getStatus()" />
<apex:outputText value="{!responseStatus}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="getBody()" />
{!responseBody}
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<script>
window.onload=function()
{
doCallout();
}
</script>