Whatever message this page gives is out now! Go check it out!

InvokeCFClientFunction

Last update:
May 18, 2026

Description

ColdFusion automatically determines whether a function call is synchronous or asynchronous. However, if you need to invoke an asynchronous function in a synchronous mode, you can use the invokeCFClientFunction function. The function call just needs to be wrapped around with the invokeCFClientFunction function call. For instance, invokeCFClientFunction(myAsyncFunc(arg1,arg2)).
The invokeCFClientFunction function can be used to invoke both synchronous and asynchronous CFML functions from JavaScript.

History

ColdFusion 11: Added this function

Syntax

invokeCFClientFunction(funcName, arg1, arg2, …., successCallback)

Properties

Parameter
Description
funcname
Required. The function to be invoked.
arguments
Optional. Arguments to pass to the function.
succesCallbackThe callback handler when the function gets invoked successfully. The successCallback argument is mandatory. If there is no successCallback, use null.

Example

The following code depicts a simple usage of file creation on the device. Since file creation is an asynchronous operation, we are using the invokeCFClientFunction to invoke this function.
<cfclientsettings enableDeviceAPI=true>
<cfclient>


<cffunction access="public" name="createfile" returntype="void" >

</cffunction>


</cfclient>
File name : <input id="filename" type="text"/>

<button onclick="invokeCFClientFunction('createfile',null)">Create a file</button>
<br> <b>Result :</b><div id="result"></div>


<script type="text/javascript">
function showresult(obj)
{
return JSON.stringify(obj);
}
</script>
For more information on using this function, see this community blog post.

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page