[SalesForce] Call a @RemoteAction from a custom button

I would like to call an @RemoteAction method from a custom button. I am aware that it is already possible to call a WebService method.

The view page of my object is already a visualforce page override, if this increases my options.

I have put the following code into a javascript button

Visualforce.remoting.Manager.invokeAction("TokenInputHelper.getExistingTokens", "{!Project__c.Id}", function(result, event) {
    if (event.status) {
        alert(event.message);
        //TODO: Do something with response
    } else if (event.type === 'exception') {
        alert(event.message);
    }
});

but I get the following error message, which makes me think this is not possible:

A problem with the OnClick JavaScript for this button or link was encountered: Visualforce is not defined

Best Answer

Visualforce includes a bunch of javascript stub methods and helpers based on the controllers used that have @RemoteAction methods in them. Custom buttons lack the intelligence to do this and I believe @RemoteAction calls are not possible in this way from buttons.

That at least would be the official answer, if you were willing to reverse engineer how @RemoteAction methods actually pass data back to the server it may be possible to make an unsupported implementation.