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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfajaxproxy and cfcs

Status
Not open for further replies.

jimmyshoes

Programmer
Jun 1, 2008
132
GB
I am experimenting with setting session variables using cfajaxproxy

Code:
cfm page......

<cfajaxproxy cfc="m" jsclassname="myproxy">
<script>
var myCFC = new myproxy()

function showIt() {
    return myCFC.myFunc()
}    

alert(showIt());

</script>

Code:
cfc.......
<cfcomponent output="false">

<cffunction name="basemethod" access="remote" returnType="string" output="false">
    <cfreturn session.someVar>
</cffunction>

</cfcomponent>

Here's the problem

The cfc cannot access the session variable when called via cfajaxproxy but t does work if called via createObject

Is there a solution to this
 
is the session defined?
are you getting any kind of return or error?
can you create a local variable/value and return that (make sure the proxy is connecting)?

is your cfc in the same folder as the cfm?

The CFC for which to create a proxy. You must specify a dot-delimited path to the CFC. The path can be an absolute filepath, or relative to location of the CFML page. For example, if the myCFC CFC is in the cfcs subdirectory of the ColdFusion page, specify cfcs.myCFC.
 
+1 to what TruthInSatire said. use this:

Code:
<cfdump var="#session#">

to see if any session vars is defined. Also, I just used the following:

test.cfm :
Code:
<cfajaxproxy cfc="m" jsclassname="myproxy">

<script>
var myCFC = new myproxy()

function showIt() {
    return myCFC.basemethod();
}    

alert(showIt());
</script>

m.cfc
Code:
<cfcomponent output="false">

<cffunction name="basemethod" access="remote" returnType="string" output="false">
	<cfset var someVar = now()>
    <cfset session.someVar = someVar>
    <cfreturn session.someVar>
</cffunction>

</cfcomponent>

they are both under the same dir. when i run test.cfm, i get a javascript alert with #now()#.

hth

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top