3 Replies Latest reply on Feb 28, 2007 3:50 PM by Charlie Griefer

    Access CFC in Javascript

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

      Now is it at all possible to access this from JavaScript?
        • 1. Re: Access CFC in Javascript
          Charlie Griefer Level 1
          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.
          • 2. Re: Access CFC in Javascript
            Dinghus Level 1
            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.
            • 3. Re: Access CFC in Javascript
              Charlie Griefer Level 1
              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?