Custom sample of AntLike button with ajax request

In this example, for loading and updating, the AntLike button is dependent on Ajax Post requests.

A Json object, LikeVM, is used to communicate with server. It's based on a boolean to define its state and an integer for its counter.

On loading, the AntLike button is initialized with LikeVM.

When the AntLike button is clicked, it sends its current state, like or unlike and the value of counter by ajax Post request, and it receives its new state and value of counter.


Source Code


//initialisation of AntLikeButton
$("#AntLikeButton").AntLike({//Custom parameters
    events:{
        onLoad: {
            enabled: true, //boolean to activate the load event
            url:"../public/php/load.php" //the url to load initial values
        },
        onClick: {
            url:"../public/php/update.php" //the url to update values
        }
    }
});