• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Access CFC in Javascript

Contributor ,
Feb 28, 2007 Feb 28, 2007

Copy link to clipboard

Copied

Okay, so I did the whole
<cfinvoke component="myCFC" method="init" returnvariable="myObj">

Now is it at all possible to access this from JavaScript?
TOPICS
Advanced techniques

Views

239

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 28, 2007 Feb 28, 2007

Copy link to clipboard

Copied

it's no different than any other CF code.

you can do:

<script type="text/javascript">
var myVariable = "#myObj.foo()#";
</script>

(assuming the foo() method returns a string... and that the code is within <cfoutput> blocks)

but whether it's a CFC or any other CF code, you still have the client side (JS) / server side (CF) issues.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 28, 2007 Feb 28, 2007

Copy link to clipboard

Copied

Yep. I think that is why it isn't working. When I did what you have there, it threw an error. Have to find another way to do this I guess.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 28, 2007 Feb 28, 2007

Copy link to clipboard

Copied

LATEST
the code i used as an example should work.

it's no different than:

<cfset myname = "charlie" />
<cfoutput>
<script type="text/javascript">
var myName = "#variables.myname#";
</script>
</cfoutput>

that's legal and works fine, and is conceptually the same as what i posted above. what specific error are you getting?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation