[SalesForce] oncomplete does NOT work when used with

<apex:actionFunction name="submitExpJS" action="{!submitExpenses}"  
    oncomplete="refreshMe();" reRender="messagePanel"/>  

<script>
function refreshMe() {    
    alert('refresh');  
}  
</script>

The function refreshMe() is not getting invoked.

Best Answer

I thought I would post this working sample code that I tried in my Developer edition org.

Controller:

public with sharing class SimplePageController {

    public Integer i{get;set;}

    public SimplePageController(){
        i =0;
    }

    public void justIncrement(){
        i = i+1;
        System.debug('From doNothing method on the controller');
    }

}

VF page:

<apex:page controller="SimplePageController" showHeader="false" Sidebar="false">
    <apex:form>
        <apex:outputPanel id="someDiv">
            <apex:outputText value="{!i}"></apex:outputText>
        </apex:outputPanel>
        <a href="#" onclick="actionFunctionJS();">Click Here</a> 
        <apex:actionFunction name="actionFunctionJS" 
                                action="{!justIncrement}" 
                                oncomplete="onCompleteJSFunction();" 
                                reRender="someDiv">
        </apex:actionFunction>
    </apex:form>

    <script type="text/javascript">
        function onCompleteJSFunction(){
            alert('From onCompleteJSFunction method');
        }
    </script>   
</apex:page>