0

im working on an upload script. im sending data with a method and im getting answer from another method. Example:

var a =new function(){
   this.start  = function(x,y,callback){

       this.finish = callback; /*php calls a.finish(someparams,moreparams)*/


   }
}

i want execute another function when a.finish executed. is that possible? Thanks for help.

1 Answer 1

1

Instead of directly assigning callback to this.finish, you can assign function which calls the other function and callback:

this.finish = function() {
    anotherFunction();
    callback.apply(this, arguments);
};
2
  • i have try this but there can be more parameters in callback function. or less... Commented Mar 27, 2014 at 15:36
  • 1
    Then use callback.apply(this, arguments);. You can do the same with the other function. Commented Mar 27, 2014 at 15:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.