function firstCallme(iWantToBePassed) {
post(callbackFun);
}
// This function shouldn't be anonymous.
function callbackFun(dataFromPostFun) {
alert(iWantToBePassed);
}
How to pass the variable iWantToBePassed from firstCallme() to callbackFun()? There are several similiar question in SO. But I couldn't identify the solution from it.
I know only one solution as given below:
function firstCallme(iWantToBePassed) {
post(function(data){callbackFun(data,iWantToBePassed) });
}
// This function shouldn't be anonymous.
function callbackFun(dataFromPostFun, iWantToBePassed) {
alert(iWantToBePassed);
}
Is there any better solution?
UPDATE:
here:
function post(callbackFun) {
jQuery.post('url', 'data', callbackFun, 'json');
}