Reputation: 169
This might have been asked before, but I can't find any good examples on how to accomplish this.
I have a callback which is fired. But inside this callback i need to add a new parameter to the ending callback function. How can I do this:
var form_to_submit = function() {
var parameters = {
param1 : "1",
param2 : "2"
}
// do_something with the parameters
}
first_function(form_to_submit);
function first_function(form_to_submit) {
if($.isFunction(form_to_submit)) {
var token = "new parameter"; // this parameter should be added to parameters in form_to_submit()
form_to_submit(); // need to pass on the token to this function call
}
}
Upvotes: 0
Views: 117
Reputation: 78520
if($.isFunction(form_to_submit)) {
var token = data['token'];
form_to_submit(token); // need to pass on the token to this function call
} else {
form_to_submit.submit();
}
I think the syntax you are looking for is that of the above. You don't need to modify the if($.isFunction(form_to_submit))
line because all you're telling it is to use that function. At that point it doesn't care about parameters.
Upvotes: 2