Hi,
you can also write
$.post('test.cgi', params, function(data) { myCallback(data,arg1,...);});
function myCallback()data, arg1,...){...}
if you need to pass arguments, other than data, to callback function
salvatore
- Original Message -
From: james_027 [EMAIL PROTECTED]
To: jQuery
James,
In:
$.post('test.cgi', params,
function(data) {
alert(data);
}
);
where data that is being passed thru the function to the alert is the
argument that the $.post function is passing it.
and:
$.post('test.cgi', params, alert(data));
where data, if not set, will alert undefined
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
Hi benjamin,
Thanks for your fast reply. Thanks for explaining things ... If I
understand it correct data is something $.post created right?
Things now make sense.
james
On Jul 12, 10:32 am, Benjamin Sterling
[EMAIL PROTECTED] wrote:
James,
In:
$.post('test.cgi', params,
function(data)
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
5 matches
Mail list logo