Hi am having problems returning a value from an ajax request.
var TESTReturnable;
var bDone = false;
function test() {
getUserImage(25016275);
do { } while (!bDone);
alert(TESTReturnable);
}
function getUserImage(userID) {
new Ajax.Request('users.json', {
method: 'get',
requestHeaders: { Accept: 'application/json' },
onSuccess: function (transport) {
var obj = transport.responseText.evalJSON();
var i = 0;
for (i = 0; i < obj.length; i++) {
if (obj[i].id == userID) {
TESTReturnable = 'Gold';
bDone = true;
}
}
}
});
}
That is my code assume that the obj[i] is set to true.
html contains
<body onload="test()"> however the Javascript alert will either not
show or display undefined; How can I get this function to return a
value as I have multiple requests to load a page.
Regards
--
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.