Way To Access Variable Value On Oncomplete Function

In this post, I will show you a simple way to access Variable value on Oncomplete function. In the below example, On command button click, Code is changing the default value of ‘isUpdated’ variable from false to true and then showing an alert message with its updated value.

we can also execute Javascript after Action Function completes using Oncomplete function .

Please have a look on below example.

public class ApexController {
        public boolean isUpdated { get; set;}
        public ApexController() {
            isUpdated = false;
        public void updateVariable() {
            isUpdated = true;
Visualforce Page:
<apex: page controller = "ApexController" >
  <apex: outputPanel id = "oPanel" >
    <script >
      function accessVariable() {
          var updated = '{!isUpdated}';
      <apex:commandButton value ="Update Variable" action = "{!updateVariable}" rerender = "oPanel" oncomplete = "accessVariable();" / >