Ollie wrote:
>> You're calling update, getting the result (undefined), then using this
>> result as a value for onComplete.  This code yields infinite recursion,
>> I guess.
> 
> I thought that onComplete function was executed after the Ajax request
> was over.
> Is this true?

It does.

> Maybe I'm not understanding what you mean.

It seems you aren't understanding the difference between calling a function and
just referring to it.

function hello(name) { alert('hello ' + name) };

hello('Michael'); // this executes hello
var bar = hello; // this just "references" hello

onComplete takes a function. you were instead passing it the return value of
your update() function which means you were executing it.

Since prototype doesn't yet support currying, if you need to reference a
function while passing it arguments you need to instead wrap the call to your
function inside of an anonymous function.

var bar = function() { hello('Michael') };

Unlike some languages (Java, C#) in Javascript functions are objects too.

-- 
Michael Peters
Developer
Plus Three, LP


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to