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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.


Reply via email to