Question

As a ColdFusion developer I have never used threading or asynchronous programming model (except ajax). invokeCFClientFunction() is a new function intorduced in cfclient to call coldfusion functions asynchronously. But I am bit confused about when we should use this function. I ran this example from cfclient documentation

<cfClientSettings detectDevice=true />


<cfclient>


<cffunction access="public" name="showCanvasSupport" returntype="void" >
     <cfset evalStr = "document.getElementById('canvas').innerHTML='"                
                       & cfclient.canvas & "'">
     <cfset eval(#evalStr#)>
</cffunction>          


</cfclient>


Canvas support -<b id="canvas"></b><br>
<button onclick="invokeCFClientFunction('showCanvasSupport',null)">
Show canvas support
</button>

I called with out using invokeCFClientFunction() <button onclick="showCanvasSupport()"> , It is also working fine.

So any idea In which cases we we should use it?

Was it helpful?

Solution

I have asked the same question to one of the engineers from Adobe. Here is the blog explaining everything, Why invokecfclientfunction?

OTHER TIPS

Turn it around, Deepak: what are your expectations one way or the other? For one way it not working fine? That doesn't make a lot of sense.

The docs ("Synchronous and asynchronous function calls") are fairly vague, but you seem to have not read them. Because the key part - the raison d'etre of the function - is:

If you are invoking an asynchronous ColdFusion function from JavaScript, the invokeCFClientFunction must be used.

And you're calling a function - showCanvasSupport() - which has no async element to it. So:

  1. why are you even trying to use invokeCFClientFunction() in the first place?
  2. What are you hoping to achieve by doing so?

It seems to me like you'r just trying code at random, and then scratching your head when you can't see what it's doing. Why are you even looking at this function? I'm not saying you shouldn't be, but there must be a reason why you put it in your code in the first place?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top