[removed] Is it possible to pass a variable into a callback function that is assigned to a variable?

后端 未结 5 794
谎友^
谎友^ 2020-12-11 00:38

A lot of people say that this is asked too much in the comments, which made me hesitant to ask this, but I still have not found a solution in their answers, mostly because (

5条回答
  •  盖世英雄少女心
    2020-12-11 01:32

    I belive you wanted something like that

    function handleAjaxRequest(params) {
        var context = {'b':'inner', 'c': params['c']};
        function rendered(html) {
          // render
        }
        function gotPart(part) {
            context['a'] = part;
            engine.render(context).addCallback(rendered);
        }
        ajax.getPart(params).addCallback(gotPart);
    }
    

提交回复
热议问题