Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript inside a cfc

Status
Not open for further replies.

ice78991

Programmer
Nov 20, 2006
216
Is it possible to call javascript inside a cfc

I am trying to debug a cffunction and thought an easy way of checking variable values would be through <script>alert('#somevar#')</script>

but the box is not popping up

 
Because Javascript and ColdFusion code run in completely separate spaces. Were you to render the JS back to the browser, you could see the values.

Most developers use CFDUMP as a variable-checking tool.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Pity the insomniac dyslexic agnostic. He stays up all night, wondering if there really is a dog.
 
Scope your variables in [blue]var[/blue] structs. This will make it easy to dump / debug exactly what you need.

For instance:

Code:
<cffunction name=".....>
    <cfargument name=".......>

    <cfset var temp = structNew()>
    <cfset var results = structNew()>

    <cftry>
        <!--- do stuff --->
        <cfcatch>
            <cfdump var="#temp#">
            <cfdump var="#results#">
        </cfcatch>
    </cftry>
</cffunction>

if you must for whatever reason use javascript alerts, I'm not sure but you can make sure that the function's output attribute is set to true
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top