Hi,
Regardless, kangax's point still holds: In your original code, you
*initiate* a request but then go on to use the value immediately,
before the request has a chance to complete. If you want to do
something with the value after the request is complete, the most
straight-forward way to do that is from the onComplete handler
(otherwise you get into timers and polling, which is a lot more mess
and no added benefit).
Your code to do something with 'something' doesn't have to be inline
in the onComplete handler, it just has to be triggered from there.
> i would like to avoid continually indenting my code into
> "onComplete" functions
If you mean that literally, an indenting issue, you can rework things
to remove a level or two of indentation:
****
var something;
new Ajax.Request("http://google.dk", {
onComplete: completeHandler
});
function completeHandler(e) {
something = e.responseText;
alert(something);
}
****
With more context, we might be able to suggest something even
cleaner...
Hope this helps,
--
T.J. Crowder
tj / crowder software / com
On Mar 7, 10:47 am, Emuen <[EMAIL PROTECTED]> wrote:
> I dont really need to alert it, i need to use it for later evaluation,
> and i would like to avoid continually indenting my code into
> "onComplete" functions.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---