function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ram Shiva KumarRam Shiva Kumar 

Action function is not working

Hi , 

I have small issue with the action function,i wrote acode in sucha way that i wnat to use the action function in my VF code . But wen i  run the VF code iam not seeing the data{'hiiiiiiiiiiiiiiiiiii) which i mentiond in the M1 method  in the debug logs\. So  i think my method m1 is not beoing called form the Java script and even aim not getting the alert also which i defined in the page. My code is ,


<apex:page controller="bang1">

<script type="text/javascript">
  
  function f1()
  {
  
  alert ('Start invoking vf action!');
  
  
  
  }
 
</script>
  
  <apex:form >
  
  
  <apex:actionFunction name="f1"   action="{!m1}"  />
  <apex:commandButton value="enter"  onclick="f1"     />
  </apex:form>
  
</apex:page>


Controller:

Public class bang1
{

Public void m1()
{

System.debug('hiiiiiiii');



}

}

Pleasesuggest me.

Regards,
Siva
Best Answer chosen by Ram Shiva Kumar
SandhyaSandhya (Salesforce Developers) 
Hi Siva,

Please see below updated code.
<apex:page controller="bang1">

<script type="text/javascript">
  
  function f1()
  {
  
  alert ('Start invoking vf action!');
  
  
  
  }
 
</script>
  
  <apex:form >
  <apex:commandButton value="enter"  onclick="f1(); return false;"/>
  <apex:actionFunction name="sadad" action="{!m1}"/>
  
  </apex:form>
  
</apex:page>
 
Public class bang1
{

public bang1()
{
m1();
}
Public void m1()
{

System.debug('hiiiiiiii');



}

}

Hope this helps you!

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya



 

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi Siva,

Please see below updated code.
<apex:page controller="bang1">

<script type="text/javascript">
  
  function f1()
  {
  
  alert ('Start invoking vf action!');
  
  
  
  }
 
</script>
  
  <apex:form >
  <apex:commandButton value="enter"  onclick="f1(); return false;"/>
  <apex:actionFunction name="sadad" action="{!m1}"/>
  
  </apex:form>
  
</apex:page>
 
Public class bang1
{

public bang1()
{
m1();
}
Public void m1()
{

System.debug('hiiiiiiii');



}

}

Hope this helps you!

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya



 
This was selected as the best answer
Ram Shiva KumarRam Shiva Kumar
Hi Sandhya,

it worked well. but while loading the page alert   function is not being called .please suggestr me for this.
Regards,
siva.
SandhyaSandhya (Salesforce Developers) 
Hi Siva,

You mean you are not getting pop up as 
alert ('Start invoking vf action!');

As I am getting in my VF page.

Thanks 
Sandhya
Ram Shiva KumarRam Shiva Kumar
Hi sandhya,

yes ,i want to get the pop upwhile page is being loaded.

Regards,
siva