Pass Extra Parameters to JavaScript Callback Function
Here is a simple example of a function that takes a callback function as a parameter.
function handleQueryResponse(response){
alert('Processing...');
}
If you wanted to pass extra variables to the callback function, you can do it like this.
var param2 ='something else';
query.send(function(response) { handleQueryResponse(response, param1, param2) });
function handleQueryResponse(response,param1,param2){
alert('Processing...');
alert(param1);
alert(param2);
}
You’re currently reading “ Pass Extra Parameters to JavaScript Callback Function ,” an entry on BRADINO
- Published:
- 10.10.09 / 4pm
- Category:
- JavaScript























Have your say