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.


ColdFusion 11: Added this function


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





Required. The function to be invoked.


Optional. Arguments to pass to the function.

succesCallback The callback handler when the function gets invoked successfully. The successCallback argument is mandatory. If there is no successCallback, use null.


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>

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


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);

For more information on using this function, see this community blog post.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy