I just set my session variables in the method I'm calling via jQuery/ajax
...any reason you can think of why that would be a bad idea?

Rick

-----Original Message-----
From: Dave Evartt [mailto:da...@wehali.com] 
Sent: Friday, November 20, 2009 4:27 PM
To: jquery-en@googlegroups.com
Subject: Re: [jQuery] JQuery and ColdFusion

I use ColdFusion and jQuery all the time with no problems. In fact, I 
use it with mach-ii.  Looks like you're using fusebox? Just a guess.

Calling the CFC directly is your problem. When you do that, it bypasses 
the application.cfm/cfc, which is normally where your session scope is 
defined. Because you are not going through the same application scope, 
your session variables won't be there.

Better to create an event (in mach-ii terms) that your application 
engine can understand and just pass it through that way, just like a 
normal browser call.

instead of:

/myapp/model/System.cfc?method=authenticate&returnFormat=json

Something like

index.cfm?fuseaction=authenticate

Then let your framework do the rest.

-dave evartt



Westside wrote:
> Hi,
>
>
> I'm trying to use ColdFusion and JQuery but I'm having some problems
> setting/reading session variables.  I have a login box that I use
> jquery to do the ajax work.  In my ajax call I have this snippet
>
>
> $(form).ajaxSubmit({
>
>
> type: 'POST',
>
> dataType: 'json',
>
> url: '/myapp/model/System.cfc?method=authenticate&returnFormat=json'
>
> success: function(resp, textStatus){
>       if(resp[0]==true){
>         window.location.href = 'index.cfm?fuseaction=myapp.home';
>       }
>
> });
>
>
> So within System.cfc there is a method called "authenticate", in this
> method I'm trying to set some session variables (e.g, session.email,
> session.title) that I can reference once the user is logged in.   So
> if the response from the ajax call returns true, the user gets
> redirected to this other page using window.location.href shown above.
>
>
> For some reason though, these session variables don't exist
> (session.email, session.title)  when I try to cfdump them out on the
> 'index.cfm?fuseaction=myapp.home' page.  I can dump them in the CFC
> and see that they are getting set correctly, but outside the CFC, they
> dont show up.  Can anyone please shed some light on why I can't see my
> session variables?  It mus thave something to do with calling the CFC
> directly or something....
>
>
> Thanks
>
>
>   



Reply via email to