In general, it does not strike me as a good idea to have JavaScript
tracking whether the user is logged... knowledgeable users could
probably get around this fairly easily.  In your cfm file redirect
them to a login page rather than trying to do it on the javascript
side of things.

You might want to look at the  'evalScripts' parameter (http://
www.prototypejs.org/api/ajax/updater) and have your cfm file
dynamically generate <script> tags depending on whether or not they
are logged in.

Al



On Jan 6, 2:08 pm, Ian Raphael <list...@gmail.com> wrote:
> Hello everybody.
>
> I'm starting to use prototype framework and i'm having a problem.
> I have an ajax javascript function that checks if the user is logged.
> This function uses coldfusion's native ajax.
>
> The code
>
> function userLogged(){
>         var $userLogin = new objUser(); //objUser is a coldfusion component
>         var result = $userLogin.getUserLoginStatus(); //getUserLoginStatus is
> a method
>
>         return result;
>
> }
>
> function checkLogged(){
>         var logged = userLogged();
>         if(logged == true)
>                 alert('logged');
>         else
>                 alert('not logged');
>
> }
>
> But i need to replace this to one written with prototype. I tried the
> code down (the return of cfm script is a JSON).
>
> function userLogged(){
>         var logged = false;
>
>         new Ajax.Request('/includes/GetUserLoginStatus.cfm', {
>         method: 'get',
>         onSuccess: function(r) {
>                 var response = r.responseText.evalJSON();
>                 var logged = response.STATUS;
>         }
>         });
>
>         return logged;
>
> }
>
> When i call this function the return always false. Obviously because
> onsuccess create another function and it doesn't change the value of
> external variable.
>
> I'm asking for you guys if there's some way to change the value of
> variable logged based on the return of the ajax call? Or there's a way
> inside onSuccess to return the response to the caller function?
>
> Thanks for the attention and sorry for my english.
> Regards, Ian
-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.


Reply via email to