I have read this:
And I still do not understand how I am meant to do it. Sorry, I am a Python programmer and only just starting to understand JavaScript.
I have this function:
this.getName(function() {
alert("Done");
});
Which has a callback to here:
this.getName = function(callback){
*doing something*
callback();
}
Which works great. The alert doesn't go off until getName()
has finished.
However I have another function, which needs to be run after getName()
has been run and completed:
this.getDetails = function(){
*Does something*
}
But I haven't got a clue how it is meant to be implemented. I have tried putting it in the first function, but it doesn't work. Any help would be much appreciated!
I have tried this:
this.getName(function(getDetails) {
alert("Done");
this.getDetails();
});