Don’t forget to tell us about your stack!
OS: Windows 10
Java Version: 8 update 391
Tomcat Version: 9
Lucee Version: 22.214.171.1245
My app was working fine until I moved from 5.3.7.047 to 126.96.36.1995 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.
It is a little unclear to me where you are trying to call the wineclubComponents.getWinestyles method. You are either:
If this is the case, you should be able to do something like:
const wineStyles = <cfoutput>#serializeJSON(resultCFC)#</cfoutput>;
- 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!!
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 5.3.7.047 where everything worked 'cos I had cfajaxproxy. Thank you all for your assistance.