I'm not sure if I'm right on this one, BUT the functioncall doesn't
stop the "flow" does it?
If so then when you do this:
if(mode == "edit"){
var userObj = getActiveUsers();
dump(userObj); // <-- This gets executed before the ajaxcall has completed.
}
And that would explain why you get the right output when using
dump(ActiveUsers) in the success part of $.ajax.
I had a similar problem, creating thumbnails in a forloop and noticed
when using firebug that I had approx 50 connections.
Oh...
Reading Karl's comment, and checking the source again... you're not
returning ActiveUsers, and it isn't a global, so unless you run into
the same problem after returning ActiveUsers you can just forget my
rambling above.
// Kristinn
On 1/30/07, Karl Rudd <[EMAIL PROTECTED]> wrote:
> Ummm perhaps you left it out of the email but where in
> getActiveUsers() do you "return ActiveUsers;"?
>
> Karl Rudd
>
> On 1/30/07, Christopher Jordan <[EMAIL PROTECTED]> wrote:
> > Hi folks,
> >
> > I have an ajax call that upon success has a variable 'result' that
> > contains a JSON encoded string. I eval that string and it becomes an
> > object (an array of structures, etc.), but when I try returning that
> > object from the function to the caller, something goes wrong. The caller
> > says that the value returned is undefined.
> >
> > so...
> > if(mode == "edit"){
> > var userObj = getActiveUsers();
> > // if I dump userObj here...
> > dump(userObj); // dump shows that userObj is undefined. :o(
> > }
> >
> > ...
> > function getActiveUsers(){
> > var ActiveUsers;
> > $.ajax({
> > type: "post",
> > url: "GetActiveUsers.cfm",
> > datatype: "html",
> > data: "",
> > success: function(r){
> > r = CFJS.Trim(r);
> > ActiveUsers = eval("(" + r + ")");
> > // if I dump the object here (using that very cool dump.js code)
> > dump(ActiveUsers); // I get exactly what I expect to see --
> > an array of structures.
> > },
> > error: function(){
> > alert("There was an error retrieving the list of active
> > users.");
> > }
> > });
> > }
> >
> > Help! :o(
> >
> > I'm really confused why this isn't working. I need serious help... asap!
> > :o( :o(
> >
> > Chris
> >
> > --
> > http://cjordan.info
> >
> >
> > _______________________________________________
> > jQuery mailing list
> > [email protected]
> > http://jquery.com/discuss/
> >
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/