send a jquery callback function inside a variable

后端 未结 5 628
小鲜肉
小鲜肉 2021-02-08 17:52

I have this jquery function

    function example(file, targetwidget, callback){

    $(targetwidget).load(file, {limit: 25}, function(){
        $(\"#widget_acco         


        
5条回答
  •  别跟我提以往
    2021-02-08 18:27

    well.. You do this way:

    function example(file, targetwidget, callback){
    
    $(targetwidget).load(file, {limit: 25}, function(){
        if(typeof(callback)==='function'){
         callback.call(this, 'other parameters');
        }
    });
    

    The paramenters of callback will help you to send data back to callback function. ATTENTION, don't forget the this keyword!

提交回复
热议问题