Cfinvoke and returnvariable

Don’t forget to tell us about your stack!

OS: Windows 10
Java Version: 8 update 391
Tomcat Version: 9
Lucee Version:

My app was working fine until I moved from to and found that cfajaxproxy was no longer available. Ok, so I hit the web to look for alternatives and settled on:

cfobject component = “wineclubComponents” name = “mycomponents”
cfinvoke component = “#mycomponents#” method = “getWinestyles” returnvariable = “resultCFC”

The problem I have is how to access the returnvariable so that I can pass it to function for processing. a cfdump var=“#resultCFC#” shows it, and identifies it as a struct, but that’s the only access I have been able to get.

What is your goal in this code? It woukd hold in that variable the result of calling that getWinestyles method.

Since you call it resultcfc, though, I sense you expected it to be an instance of that cfc. If so, that’s what’s in the mycomponents variable of the previous cfobject call: indeed, that’s what allowed you to invoke this method on that cfc instance.

If you “knew all this”, OK. Just help us again to know what you did seek.

Thank you for the response. What I’m trying to say is that everything worked well until I was unable to use cfajaxproxy. With that command available, in order to retrieve the contents of a database table using the cfc getWinestyles, was to:


and this passed the STRUCT from the cfc to the function populateVTable.

So now I’m trying to do the same thing another way and pass the response from my cfc (resultCFC) to the function populateVTable but I don’t know how.

I should have explained that all of my application is written in javascript, so having to use CF means I have to know how to pass variables back and forth between CF and JS and I was hoping that someone else may have already done this.

It is a little unclear to me where you are trying to call the wineclubComponents.getWinestyles method. You are either:

  1. Calling it on the same page that you have your JavaScript being output and need to get the resultCFC variables into a format that JavaScript can use.
    If this is the case, you should be able to do something like:
const wineStyles = <cfoutput>#serializeJSON(resultCFC)#</cfoutput>;
  1. Or are wanting to make an ajax request to get the resultCFC data from a remote call. If this is the case then you should look at something like Axios to replace your old cfajax code:
    Getting Started | Axios Docs

Martin, thank you, thank you! Point 1 described my situation and your code provided the solution to my dilemma!!

OK, pushing further on, how do I pass a javascript array and/or a variable to a CFC via the cfinvoke argument collection?

Well, it seems I must be screwing up somehow because I’m now getting errors from working code which hasn’t been touched. This is all too hard for what is essentially a hobby coding exercise. I’m going back to my previous version of Lucee where everything worked 'cos I had cfajaxproxy. Thank you all for your assistance.