Hi,

Is javascript closure different from closure of the other languages?
Thanks for explaining things and the article you shared.

james

On Jul 12, 10:03 am, Eric Crull <[EMAIL PROTECTED]> wrote:
> The first example is a closure.  It only operates when the $.post
> function is completed.  If you just tried to use the alert(data) as
> you have in the second example it would execute right away.
>
> A closure is the equivalent to burying a time-capsule in the ground to
> be dug up later.  You could leave the box open and the stuff in it
> lying around, but then it wouldn't be valuable, would it?
>
> What you do is close the box up and put it away until the time is
> right to look inside it.  Then when the time comes (after the $.post),
> it is dug up and the contents examined.
>
> Try reading this, it's accessible and the examples are fairly easy to
> understand...
>
> http://blog.morrisjohns.com/javascript_closures_for_dummies
>
> Don't worry if you don't get it right away, that just means you're a
> mere mortal.
>
> Eric
>
> On Jul 11, 9:40 pm, james_027 <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I am using $.post() function, I don't understand what is callback
> > function ...
>
> > what is the difference between
>
> > $.post('test.cgi', params,
> >     function(data) {
> >         alert(data);
> >     }
> > );
>
> > and
>
> > $.post('test.cgi', params, alert(data));
>
> > the data being shown is different. and I don't seem to understand what
> > is the difference in function(data) {alert(data);} from alert(data).
> > For me function(data) {alert(data);} is just a function taking the
> > data and just passing it to the alert(). Is function() inside the
> > $.post something special? where does the data come from? are the data
> > in the function(data) {alert(data);} and alert(data) different?
>
> > Thanks
> > james

Reply via email to