signature with a callback
Posted: Mon Feb 04, 2013 1:09 am
Hi
I am trying to figure out the use of callback functions in asynchronous requests in AJAX.
I come across terms like:
"signature with a callback" or "delegate"
Would really appreciate if some one could explain what signature means in this context.
thanks a lot
I am trying to figure out the use of callback functions in asynchronous requests in AJAX.
I come across terms like:
"signature with a callback" or "delegate"
Would really appreciate if some one could explain what signature means in this context.
Code: Select all
function mySandwich(param1, param2, callback) {
alert('Started eating my sandwich.\n\nIt has: ' + param1 + ', ' + param2);
$('#sandwich').animate({
opacity: 0
}, 5000, function() {
// Animation complete.
});
if (callback && typeof(callback) === "function") {
callback(param1, param2);
}
}
mySandwich('ham', 'cheese', function(callbackParam1, callbackParam2) {
alert('Finished eating my ' + callbackParam1 + ' & ' + callbackParam2 + ' sandwich.');
});