Thursday, October 28, 2010

Javascript callback with parameter

Javascript delegates with parameter:

Here is one example for calling a javascript function using a delegate ( function pointer ) .

While calling a method using delegate, you should use the first parameter as 'this' (or an object), after that you can pass additional parameters.

For more details see the following example.

Eg:

pass a function as parameter.

do_AjaxPostWithData(url,function (str) { });


the following function calls the delegate with a parameter.
function do_AjaxPostWithData(actionUrl, callback) {

callback.call(
 
this,context.responseText);

}