How can you invoke a function in JavaScript, while passing in arguments, using a function pointer?
Example:
function foo (a, callback) {
jQuery.post('/soon/check.json', { var:a }, function(resp) {
callback(resp);
});
}
function process_json(resp) {
// Do something with resp
}
foo(bar, process_json);
process_json
never gets invoked. Looking in Firebug, the string process_json
is getting passed into foo
, but I assumed this represents a pointer to the function process_json
.
In Javascript, is it not possible to invoke functions via pointers and pass in arguments?