[SalesForce] Uncaught ReferenceError: callAF is not defined

I am trying to update the checkbox(checked or unchecked) in the database from the UI. I am calling the js function on onclick of checkbox and invoking controllers action but I am getting this error.

public class CheckboxFunctionality 
{
    public List<Account> accList{get;set;}
    public String recordId{get;set;}
    public CheckboxFunctionality()
    {
        accList = new List<Account>();
        accList = [Select id, name, phone, isActive__c  From Account Order By LastModifiedDate Limit 5];
    }

    public PageReference checkActive()
    {
        system.debug('------------'+recordId);
        Account acc = new Account();
        acc.id = recordId;
        if(acc.isActive__c == true)
            acc.isActive__c = false;
        else 
            acc.isActive__c = true;
        update acc;
        return null;
    }
}

    <apex:page controller="CheckboxFunctionality">
    <apex:form>
        <apex:actionFunction name="callAF" action="{!checkActive}" reRender="pbt">
            <apex:param id="accId" value="" assignTo="{!recordId}"/>
        </apex:actionFunction>
        <apex:pageBlock>
            <apex:pageBlockTable value="{!accList}" var="row" id="pbt">
                <apex:column>
                <apex:inputField value="{!row.isActive__c}" onclick="check('{!row.Id}')"/>
            </apex:column>
                <apex:column value="{!row.name}"/>
                <apex:column value="{!row.Phone}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    <script>
        function check(recId)
        {
            alert('---'+recId);
            callAF(recId);
            alert('122345');
        }
    </script>
</apex:page>

Also

Uncaught SyntaxError: Unexpected token :

this is coming in console.

Best Answer

Give your apex:param name attribute. So it will work.

<apex:actionFunction name="callAF" action="{!checkActive}" reRender="pbt"> <apex:param name="apparam" id="accId" value="" assignTo="{!recordId}"/> </apex:actionFunction>

This will not give you compile time error but name is the required attribute of apex:param tag