To make your call synchronous, try something like this:
if(mode == "edit"){
var userObj = getActiveUsers();
// if I dump userObj here...
dump(userObj); // dump shows that userObj is undefined. :o(
}
function getActiveUsers(){
return eval("(" + $.ajax({
type: "post",
url: "GetActiveUsers.cfm",
async: false,
error: function(){
alert("There was an error...");
}
}).responseText + ")");
}
--John
On 1/29/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> Christopher Jordan schrieb:
> > Hi folks,
> >
> > I have an ajax call that upon success has a variable 'r' 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.
> > [...]
> > Help! :o(
> >
> > I'm really confused why this isn't working. I need serious help... asap!
> > :o( :o(
> >
> Wrapping the $.ajax call in a function doesn't make the call
> synchronous. Your function returns before the success callback is
> executed. You have to restructure your code to work with the success
> callback, instead of relying on a return value.
>
> --
> Jörn Zaefferer
>
> http://bassistance.de
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/