Originally posted by Bear Bibeault:
If you can snag a copy of jQuery in Action, I go into some level of detail on this in Appendix A.
This is one of the few books i've heard from everyone that is a must-get. A friend insisted he let me borrow his, but you know how that goes...I'll pick it up sometime this week when I get a moment.
And I completely understand your above example now, I think. So, the anonymous function that was created inside the AJAXInteraction parameters has access to variables inside the same closure the ajax object was created.
Why is that needed though? Is it because the JS code would exit before the response came back and thus lose the reference to the response object? If you need to see the forum that Eric posted that originally i'll try to find it but I think it's a fairly common task. Right now I think I understand it, but I would have a hard time identifying
when I need to use it.
var ajax = new AJAXInteraction(url, function(response){ validateCallback( response, field1, field2, field3); });
[ November 18, 2008: Message edited by: Paul Yule ]