today , i noticed a very weird behaviour on actionfunction's on complete action.

When i use action function like below function works as expected :


<!--Attention : rerender attribute did not used-->
<actionfunction name="test" oncomplete="callBack('{!result}')" action="{!myServerAction}"/>
function callBack(str){

MY Server Side Method:

public string result{get;set;}
public void  myServerAction(){
this.result = "Success";

Console log:


But when i use oncomplete like below , i got blank string on output :


<!--Attention : rerender attribute did not used-->
<button onclick="test();">TEST BUTTON</button>
<actionfunction name="test" oncomplete="callBack()" action="{!myServerAction}"/>
 function callBack(){

Console Log : ""

Does anyone have idea that how the first scenario works as expected without rerender attribute ?

Thanks in advance.


This is simple. In first method you are passing updated value as parameter thats why you are getting Success there. And in the Oncomplete of actionfunction you are getting updated value there. Because Actionfunction is a VF component so when it perform action then salesforce refersh all the getter setter which also refresh the value of result and you get updated value.

In second approach you are not rerendering the section thats why you are not getting any value. rerender the section.

  • With your approach , we should see the updated result value in source html. (right click > inspect) but it is blank. So you may be wrong. May 16 '16 at 9:14
  • @erkançipil try to close inspect element and then open it again . Now check. May 16 '16 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.