Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Create Callback

I'd like to create a callback on a simple function.

I have this function which is called on button click:

function main(){ };

So I'd like main(), when its done to call this:

 function test(){ }
like image 622
jQuerybeast Avatar asked Dec 06 '25 03:12

jQuerybeast


1 Answers

function main(callback) {
    // ... do your thing
    callback();
}

main(function(){
    alert('this is the callback speaking');
});
like image 66
Michael Robinson Avatar answered Dec 09 '25 01:12

Michael Robinson