Hi, This is from How jQuery work from John,
A callback is a function that is passed as an argument to another function and is executed after its parent function has completed. The special thing about a callback is that functions that appear after the "parent" can execute before the callback executes. Another important thing to know is how to properly pass the callback. This is where I have often forgotten the proper syntax. Callback with arguments "What do you do if you have arguments that you want to pass?", you might ask yourself. Wrong The Wrong Way (will not work!) $.get('myhtmlpage.html', myCallBack(param1, param2)); This will not work because it calls myCallBack(param1, param2) then passes the return value as the second parameter to $.get(). I just want to know why callback behave like that. Is this something a jQuery feature or a javascript feature in general? Thanks On May 21, 8:58 pm, "Brandon Aaron" <[EMAIL PROTECTED]> wrote: > Welcome to jQuery! > > Could you provide some more context to your question? I'm a little > confused as to what you are asking about. In general callbacks are > used in order to keep things synchronized. Especially things like AJAX > and FX. Without callbacks we wouldn't easily be able to know when > those items where done executing. > > -- > Brandon Aaron > > On 5/21/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > I am welcoming myself to Jquery, and I am glad that I give myself a > > chance to try jquery. The documentation and tutorials which many seems > > to ignore is one of the things that makes me to go for jquery for my > > javascript & ajax need. > > > Upon finishing the How jQuery Works, I want to learn why callback > > should be executed after the parent. As a newbie to javascript/jQuery, > > I am expecting that the callback should be executed first before the > > parent. What is the reason or logic behind, and should this be the > > case everytime? > > > Thanks > > James