I have below code where I want to do an action to apex action function and oncomplete of it want to call a javascript function.

Unfortunately instead of calling the action the action function in my case, performs oncomplete javascript function call and then reloads the page.

Can anyone please help me know why such weird behavior happening here?

 <button class="slds-button slds-button_brand" onclick="return actfun();"><i class="fa fa-download" aria-hidden="true"> &nbsp; &nbsp; Download XML</i></button>
                           <apex:actionfunction name="actfun" action="{!getProcessing}"  oncomplete="move();" rerender="searchSection2"/>

Move function code

        function move() {
          var elem = document.getElementById("myBar");   
          var width = 1;
          var id = setInterval(frame, 10);
          function frame() {
            if (width >= 100) {
            } else {
              elem.style.width = width + '%'; 

  • Is the reload code present in javaScript method move? Also, did you debug and check if it is not at all going inside the method getProcessing? Jun 18 '18 at 11:34
  • Yes it's not going as if I remove oncomplete and rerender parts it perfectly goes to getprocessing and downloads an xml for me as expected. Jun 18 '18 at 11:39

With a normal button, you want to cancel the original operation:

 <button onclick="actfun(); return false;">...</button>

This will prevent your whole-page-reload scenario.

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.